Module: Joinable::ActsAsJoinable::ActMethod
- Defined in:
- lib/joinable/acts_as_joinable.rb
Instance Method Summary collapse
-
#acts_as_joinable(options = {}) ⇒ Object
Takes one option :component_permissions - a list of all of the permissions grouped by the component they affect eg.
Instance Method Details
#acts_as_joinable(options = {}) ⇒ Object
Takes one option :component_permissions - a list of all of the permissions grouped by the component they affect eg. [=> [:view, :apply, :remove, :create, :delete]]
The grouped permissions are unpacked to create distinct permissions (eg. view_labels, apply_labels, …) These unpacked permissions are put into an array with the singular permissions (eg. find) and stored in a permissions class variable.
In addition, The grouped permissions are stored in a separate component_permissions_hashes class variable.
NOTE: The permissions are passed in-order because in the view we expect to find certain permission patterns.
eg. the simple project permission level is determined by looking for a string of permissions that span
several components, (labels, writeboards, files, etc...).
TODO: Remove the aforementioned order dependency
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/joinable/acts_as_joinable.rb', line 17 def acts_as_joinable( = {}) extend ClassMethods unless (class << self; included_modules; end).include?(ClassMethods) include InstanceMethods unless included_modules.include?(InstanceMethods) .assert_valid_keys :component_permissions self. = [:component_permissions] self. = [:find, :view] ([:component_permissions]) self. += [:manage, :own] end |