Class: Controll::Flow::EventMapper::PathFinder

Inherits:
Object
  • Object
show all
Includes:
Event::Helper
Defined in:
lib/controll/flow/event_mapper/path_finder.rb

Constant Summary collapse

NoMappingFoundError =
Controll::Flow::NoMappingFoundError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Event::Helper

#create_event, #normalize

Constructor Details

#initialize(event, maps, types = []) ⇒ PathFinder

event <Event>

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
# 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

Instance Attribute Details

#eventObject

Returns the value of attribute event.



4
5
6
# File 'lib/controll/flow/event_mapper/path_finder.rb', line 4

def event
  @event
end

#mapsObject

Returns the value of attribute maps.



4
5
6
# File 'lib/controll/flow/event_mapper/path_finder.rb', line 4

def maps
  @maps
end

#typesObject

Returns the value of attribute types.



4
5
6
# File 'lib/controll/flow/event_mapper/path_finder.rb', line 4

def types
  @types
end

Instance Method Details

#pathObject



17
18
19
20
21
# 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