class Controll::Flow::ActionMapper::Complex

Attributes

action_clazz[W]
event_maps[R]
types[R]
event_maps[R]

Public Class Methods

action(controller, event) click to toggle source
# 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) click to toggle source

writer also auto-adds type to types

# 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) click to toggle source

reader

# 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) click to toggle source

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

# 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

Protected Class Methods

path_finder(event) click to toggle source
# File lib/controll/flow/action_mapper/complex.rb, line 42
def path_finder event
  raise Controll::Flow::NoMappingFoundError, "No event maps defined" if event_maps.blank?
  path_finder_class.new event, event_maps, types
end
path_finder_class() click to toggle source
# File lib/controll/flow/action_mapper/complex.rb, line 47
def path_finder_class
  Controll::Flow::EventMapper::PathFinder
end