Class: CanTango::Ability
- Inherits:
-
Object
- Object
- CanTango::Ability
- Includes:
- CanCan::Ability, CacheHelpers, EngineHelpers, 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/ability/executor.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/engine_helpers.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
Direct Known Subclasses
Defined Under Namespace
Modules: CacheHelpers, EngineHelpers, Executor, 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.
Instance Method Summary collapse
- #cached? ⇒ Boolean
- #clear_rules! ⇒ Object
- #config ⇒ Object
-
#initialize(candidate, options = {}) ⇒ Ability
constructor
Equivalent to a CanCan Ability#initialize call which executes all the permission logic.
- #permit_rules ⇒ Object
- #session ⇒ Object
- #subject ⇒ 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
Methods included from 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 = {}) ⇒ Ability
Equivalent to a CanCan Ability#initialize call which executes all the permission logic
15 16 17 18 19 20 21 22 23 |
# File 'lib/cantango/ability.rb', line 15 def initialize candidate, = {} raise "Candidate must be something!" if !candidate @candidate, @options = candidate, clear_rules! permit_rules execute_engines! if engines_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 |
Instance Method Details
#cached? ⇒ Boolean
27 28 29 |
# File 'lib/cantango/ability.rb', line 27 def cached? false end |
#clear_rules! ⇒ Object
34 35 36 |
# File 'lib/cantango/ability.rb', line 34 def clear_rules! @rules ||= default_rules end |
#config ⇒ Object
48 49 50 |
# File 'lib/cantango/ability.rb', line 48 def config CanTango.config end |
#permit_rules ⇒ Object
31 32 |
# File 'lib/cantango/ability.rb', line 31 def permit_rules end |
#session ⇒ Object
38 39 40 |
# File 'lib/cantango/ability.rb', line 38 def session @session = [:session] || {} # seperate session cache for each type of user? end |
#subject ⇒ Object
42 43 44 45 46 |
# File 'lib/cantango/ability.rb', line 42 def subject return candidate.active_user if masquerade_user? return candidate.active_account if masquerade_account? candidate end |