Class: CanTango::Executor::PermitType

Inherits:
Base
  • Object
show all
Defined in:
lib/cantango/executor/permit_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ability, permit_type, permits) ⇒ PermitType

Returns a new instance of PermitType.



9
10
11
12
13
# File 'lib/cantango/executor/permit_type.rb', line 9

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.



7
8
9
# File 'lib/cantango/executor/permit_type.rb', line 7

def ability
  @ability
end

#permit_typeObject (readonly) Also known as: cache_key

Returns the value of attribute permit_type.



7
8
9
# File 'lib/cantango/executor/permit_type.rb', line 7

def permit_type
  @permit_type
end

#permitsObject (readonly)

Returns the value of attribute permits.



7
8
9
# File 'lib/cantango/executor/permit_type.rb', line 7

def permits
  @permits
end

Instance Method Details

#cacheObject



17
18
19
# File 'lib/cantango/executor/permit_type.rb', line 17

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

#execute!Object



21
22
23
24
25
26
27
# File 'lib/cantango/executor/permit_type.rb', line 21

def execute!
  # 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