Class: Controll::Flow::ActionMapper::Complex

Inherits:
Base
  • Object
show all
Defined in:
lib/controll/flow/action_mapper/complex.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

path_action_class

Class Attribute Details

.action_clazz=(value) ⇒ Object (writeonly)

Sets the attribute action_clazz

Parameters:

  • value

    the value to set the attribute action_clazz to.



6
7
8
# File 'lib/controll/flow/action_mapper/complex.rb', line 6

def action_clazz=(value)
  @action_clazz = value
end

.event_mapsObject (readonly)

Returns the value of attribute event_maps.



7
8
9
# File 'lib/controll/flow/action_mapper/complex.rb', line 7

def event_maps
  @event_maps
end

.typesObject (readonly)

Returns the value of attribute types.



7
8
9
# File 'lib/controll/flow/action_mapper/complex.rb', line 7

def types
  @types
end

Instance Attribute Details

#event_mapsObject (readonly)

Returns the value of attribute event_maps.



3
4
5
# File 'lib/controll/flow/action_mapper/complex.rb', line 3

def event_maps
  @event_maps
end

Class Method Details

.action(controller, event) ⇒ Object



16
17
18
19
20
# File 'lib/controll/flow/action_mapper/complex.rb', line 16

def action controller, event
  action_types ||= types
  path = path_finder(event).path
  path_action_class.new controller, path unless path.blank?
end

.event_map(*args, &block) ⇒ Object

writer also auto-adds type to types



30
31
32
33
34
35
36
37
38
# File 'lib/controll/flow/action_mapper/complex.rb', line 30

def event_map *args, &block
  @event_maps ||= {}
  @types ||= []
  return @event_maps if args.empty? && !block_given?

  type = args.first.kind_of?(Symbol) ? args.shift : :notice        
  event_maps[type.to_sym] = block_given? ? instance_eval(&block) : args.first
  @types << type unless types.include?(type)
end

.event_map_for(type = :notice) ⇒ Object

reader



23
24
25
26
# File 'lib/controll/flow/action_mapper/complex.rb', line 23

def event_map_for type = :notice
  @event_maps ||= {}
  event_maps[type.to_sym] || {}
end

.inherited(base) ⇒ Object

this method could be generated whenever a class inherits from ActionHandler class?



10
11
12
13
14
# File 'lib/controll/flow/action_mapper/complex.rb', line 10

def inherited base
  if base.parent.respond_to? :add_action_handler
    base.add_action_handler self.name.demodulize
  end
end