Class: CanTango::PermissionEngine::Collector
- Inherits:
-
Object
- Object
- CanTango::PermissionEngine::Collector
- Includes:
- Helpers::Debug
- Defined in:
- lib/cantango/permission_engine/collector.rb
Instance Attribute Summary collapse
-
#ability ⇒ Object
readonly
Returns the value of attribute ability.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(ability, permissions, type) ⇒ Collector
constructor
A new instance of Collector.
- #relevant_rules ⇒ Object
- #role_groups_list ⇒ Object
- #roles_list ⇒ Object
- #selector ⇒ Object
- #user ⇒ Object
- #user_account ⇒ Object (also: #account)
- #user_key_field ⇒ Object
Methods included from Helpers::Debug
Constructor Details
#initialize(ability, permissions, type) ⇒ Collector
Returns a new instance of Collector.
8 9 10 11 12 13 |
# File 'lib/cantango/permission_engine/collector.rb', line 8 def initialize ability, , type debug "Collecting #{type} permissions" @ability = ability @permissions = @type = type end |
Instance Attribute Details
#ability ⇒ Object (readonly)
Returns the value of attribute ability.
6 7 8 |
# File 'lib/cantango/permission_engine/collector.rb', line 6 def ability @ability end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
6 7 8 |
# File 'lib/cantango/permission_engine/collector.rb', line 6 def @permissions end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/cantango/permission_engine/collector.rb', line 6 def type @type end |
Instance Method Details
#build ⇒ Object
15 16 17 18 19 |
# File 'lib/cantango/permission_engine/collector.rb', line 15 def build relevant_rules.inject([]){|evaluators, (name, rules)| evaluators << CanTango::PermissionEngine::Evaluator.new(ability, rules) } end |
#relevant_rules ⇒ Object
21 22 23 |
# File 'lib/cantango/permission_engine/collector.rb', line 21 def relevant_rules selector.select end |
#role_groups_list ⇒ Object
29 30 31 |
# File 'lib/cantango/permission_engine/collector.rb', line 29 def role_groups_list ability.role_groups end |
#roles_list ⇒ Object
33 34 35 |
# File 'lib/cantango/permission_engine/collector.rb', line 33 def roles_list ability.roles end |
#selector ⇒ Object
25 26 27 |
# File 'lib/cantango/permission_engine/collector.rb', line 25 def selector CanTango::PermissionEngine::Selector.create type, self end |
#user ⇒ Object
37 38 39 |
# File 'lib/cantango/permission_engine/collector.rb', line 37 def user ability.user end |
#user_account ⇒ Object Also known as: account
41 42 43 |
# File 'lib/cantango/permission_engine/collector.rb', line 41 def user_account ability.user_account end |
#user_key_field ⇒ Object
46 47 48 |
# File 'lib/cantango/permission_engine/collector.rb', line 46 def user_key_field ability.user_key_field end |