Class: CanTango::AbilityExecutor
- Defined in:
- lib/cantango/ability_executor.rb
Instance Attribute Summary
Attributes inherited from Ability
Instance Method Summary collapse
- #cached_ability ⇒ Object
- #cached_rules ⇒ Object
-
#initialize(candidate, options = {}) ⇒ AbilityExecutor
constructor
A new instance of AbilityExecutor.
- #non_cached_ability ⇒ Object
- #non_cached_rules ⇒ Object
- #rules ⇒ Object
Methods inherited from Ability
#cached?, #clear_rules!, #config, #permit_rules, #session, #subject
Methods included from CanTango::Ability::RoleHelpers
Methods included from Helpers::RoleMethods
#config, #has_role_group_meth, #has_role_meth, #role_groups_list_meth, #roles_list_meth
Methods included from CanTango::Ability::UserHelpers
#user, #user_account, #user_key_field
Methods included from CanTango::Ability::PermitHelpers
Methods included from CanTango::Ability::MasqueradeHelpers
#masquerade_account?, #masquerade_user?, #masquerading?, #masquerading_off?
Methods included from CanTango::Ability::CacheHelpers
Methods included from CanTango::Ability::EngineHelpers
#each_engine, #engines, #engines_on?, #execute_engines!, #opts_engines_off?
Methods included from PermitEngine::Util
#localhost_manager?, #permit_name, #role
Constructor Details
#initialize(candidate, options = {}) ⇒ AbilityExecutor
Returns a new instance of AbilityExecutor.
4 5 6 7 8 9 10 |
# File 'lib/cantango/ability_executor.rb', line 4 def initialize candidate, = {} raise "Candidate must be something!" if !candidate @candidate, @options = [candidate, ] @rules = cached_rules + non_cached_rules rules.flatten! rules.compact! end |
Instance Method Details
#cached_ability ⇒ Object
24 25 26 |
# File 'lib/cantango/ability_executor.rb', line 24 def cached_ability CanTango::CachedAbility.new candidate, end |
#cached_rules ⇒ Object
16 17 18 |
# File 'lib/cantango/ability_executor.rb', line 16 def cached_rules cache_mode? ? cached_ability.send(:rules) : [] end |
#non_cached_ability ⇒ Object
28 29 30 |
# File 'lib/cantango/ability_executor.rb', line 28 def non_cached_ability CanTango::Ability.new candidate, end |
#non_cached_rules ⇒ Object
20 21 22 |
# File 'lib/cantango/ability_executor.rb', line 20 def non_cached_rules no_cache_mode? ? non_cached_ability.send(:rules) : [] end |
#rules ⇒ Object
12 13 14 |
# File 'lib/cantango/ability_executor.rb', line 12 def rules @rules ||= [] end |