Class: CanTango::Permits::Executor

Inherits:
Object
  • Object
show all
Includes:
Ability::Executor
Defined in:
lib/cantango/permits/executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Ability::Executor

#clear_rules!, #engine_name, #execute!, #rules

Methods included from Helpers::RoleMethods

#config, #has_role_group_meth, #has_role_meth, #role_groups_list_meth, #roles_list_meth

Methods included from Helpers::Debug

#debug

Constructor Details

#initialize(ability, permit_type, permits) ⇒ Executor

Returns a new instance of Executor.



11
12
13
14
15
# File 'lib/cantango/permits/executor.rb', line 11

def initialize ability, permit_type, permits
  @ability      = ability
  @permit_type  = permit_type
  @permits      = permits
end

Instance Attribute Details

#abilityObject (readonly)

Returns the value of attribute ability.



9
10
11
# File 'lib/cantango/permits/executor.rb', line 9

def ability
  @ability
end

#permit_typeObject (readonly) Also known as: cache_key

Returns the value of attribute permit_type.



9
10
11
# File 'lib/cantango/permits/executor.rb', line 9

def permit_type
  @permit_type
end

#permitsObject (readonly)

Returns the value of attribute permits.



9
10
11
# File 'lib/cantango/permits/executor.rb', line 9

def permits
  @permits
end

Instance Method Details

#cacheObject



19
20
21
# File 'lib/cantango/permits/executor.rb', line 19

def cache
  @cache ||= CanTango::Ability::Cache.new self, :cache_key => cache_key, :key_method_names => key_method_names
end

#permit_rulesObject



23
24
25
26
27
28
29
# File 'lib/cantango/permits/executor.rb', line 23

def permit_rules
  # TODO: somehow type specific caching of result of permits!
  permits.each do |permit|
    CanTango.config.permits.was_executed(permit, ability) if CanTango.debug?
    break if permit.execute == :break
  end
end