Class: CanTango::Ability
- Inherits:
-
Object
- Object
- CanTango::Ability
- Includes:
- CanCan::Ability, CacheHelpers, MasqueradeHelpers, PermissionHelpers, PermitHelpers, RoleHelpers, UserHelpers, PermitEngine::Util
- Defined in:
- lib/cantango/ability.rb,
lib/cantango/ability/cache.rb,
lib/cantango/ability/scope.rb,
lib/cantango/adapter/moneta.rb,
lib/cantango/adapter/compiler.rb,
lib/cantango/ability/cache/key.rb,
lib/cantango/ability/cache/reader.rb,
lib/cantango/ability/cache/writer.rb,
lib/cantango/ability/role_helpers.rb,
lib/cantango/ability/user_helpers.rb,
lib/cantango/ability/cache_helpers.rb,
lib/cantango/ability/cache/kompiler.rb,
lib/cantango/ability/permit_helpers.rb,
lib/cantango/ability/cache/base_cache.rb,
lib/cantango/ability/cache/rules_cache.rb,
lib/cantango/ability/cache/moneta_cache.rb,
lib/cantango/ability/masquerade_helpers.rb,
lib/cantango/ability/permission_helpers.rb,
lib/cantango/ability/cache/session_cache.rb
Defined Under Namespace
Modules: CacheHelpers, MasqueradeHelpers, PermissionHelpers, PermitHelpers, RoleHelpers, UserHelpers Classes: Cache, Scope
Instance Attribute Summary collapse
-
#candidate ⇒ Object
readonly
Returns the value of attribute candidate.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #clear_rules! ⇒ Object
- #config ⇒ Object
- #each_engine(&block) ⇒ Object
- #engines ⇒ Object
- #execute_engines! ⇒ Object
-
#initialize(candidate, options = {}) ⇒ Ability
constructor
Equivalent to a CanCan Ability#initialize call which executes all the permission logic.
- #permit_rules ⇒ Object
Methods included from RoleHelpers
Methods included from Helpers::RoleMethods
#has_role_group_meth, #has_role_meth, #role_groups_list_meth, #roles_list_meth
Methods included from UserHelpers
#user, #user_account, #user_key_field
Methods included from PermitHelpers
Methods included from MasqueradeHelpers
#masquerade_account?, #masquerade_user?, #masquerading?, #masquerading_off?
Methods included from CacheHelpers
#cache, #cache_rules!, #cached_rules, #cached_rules?
Methods included from PermitEngine::Util
#localhost_manager?, #permit_name, #role
Constructor Details
#initialize(candidate, options = {}) ⇒ Ability
Equivalent to a CanCan Ability#initialize call which executes all the permission logic
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cantango/ability.rb', line 15 def initialize candidate, = {} raise "Candidate must be something!" if !candidate @candidate, @options = candidate, @session = [:session] || {} # seperate session cache for each type of user? return if cached_rules? clear_rules! permit_rules execute_engines! cache_rules! if caching_on? end |
Instance Attribute Details
#candidate ⇒ Object (readonly)
Returns the value of attribute candidate.
11 12 13 |
# File 'lib/cantango/ability.rb', line 11 def candidate @candidate end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/cantango/ability.rb', line 11 def @options end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
11 12 13 |
# File 'lib/cantango/ability.rb', line 11 def session @session end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
11 12 13 |
# File 'lib/cantango/ability.rb', line 11 def subject @subject end |
Instance Method Details
#clear_rules! ⇒ Object
34 35 36 |
# File 'lib/cantango/ability.rb', line 34 def clear_rules! @rules = [] end |
#config ⇒ Object
56 57 58 |
# File 'lib/cantango/ability.rb', line 56 def config CanTango.config end |
#each_engine(&block) ⇒ Object
42 43 44 |
# File 'lib/cantango/ability.rb', line 42 def each_engine &block engines.execution_order.each {|name| yield engines.registered[name] if engines.active? name } end |
#engines ⇒ Object
46 47 48 |
# File 'lib/cantango/ability.rb', line 46 def engines CanTango.config.engines end |
#execute_engines! ⇒ Object
38 39 40 |
# File 'lib/cantango/ability.rb', line 38 def execute_engines! each_engine {|engine| engine.new(self).execute! if engine } end |
#permit_rules ⇒ Object
31 32 |
# File 'lib/cantango/ability.rb', line 31 def permit_rules end |