class Controll::Flow::EventMapper::PathFinder

Constants

NoMappingFoundError

Complex mapper

Attributes

event[RW]
maps[RW]
types[RW]

Public Class Methods

new(event, maps, types = []) click to toggle source

event <Event>

# File lib/controll/flow/event_mapper/path_finder.rb, line 9
def initialize event, maps, types = []
  raise ArgumentError, "Event argument must not be empty" if event.blank?
  raise ArgumentError, "Maps argument must not be empty" if maps.blank?
  @event = normalize event
  @types = types unless types.blank?
  @maps = maps
end

Public Instance Methods

path() click to toggle source
# File lib/controll/flow/event_mapper/path_finder.rb, line 17
def path
  @path ||= mapper.map_event 
rescue StandardError => e
  raise NoMappingFoundError, "No event mapping could be found for: #{event.inspect} in: #{maps}. Cause: #{e}"
end

Protected Instance Methods

event_map() click to toggle source
# File lib/controll/flow/event_mapper/path_finder.rb, line 27
def event_map
  @event_map ||= maps[event.type] || {}
end
mapper() click to toggle source
# File lib/controll/flow/event_mapper/path_finder.rb, line 31
def mapper
  @mapper ||= Controll::Flow::EventMapper::Util.new event, event_map
end