Class: Controll::Flow::EventMapper::Util
- Inherits:
-
Object
- Object
- Controll::Flow::EventMapper::Util
- Includes:
- Event::Helper
- Defined in:
- lib/controll/flow/event_mapper/util.rb
Constant Summary collapse
- NoMappingFoundError =
Controll::Flow::NoMappingFoundError
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#event_map ⇒ Object
readonly
Returns the value of attribute event_map.
Instance Method Summary collapse
-
#initialize(event, event_map) ⇒ Util
constructor
A new instance of Util.
-
#map_event ⇒ Object
An event can also be a Symbol, in which case it is a :notice event.
Methods included from Event::Helper
Constructor Details
#initialize(event, event_map) ⇒ Util
Returns a new instance of Util.
8 9 10 11 12 13 14 15 |
# File 'lib/controll/flow/event_mapper/util.rb', line 8 def initialize event, event_map @event ||= normalize event unless valid_map? event_map raise ArgumentError, "Invalid redirect map: #{event_map}, must be a non-empty Hash" end @event_map ||= event_map end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
4 5 6 |
# File 'lib/controll/flow/event_mapper/util.rb', line 4 def event @event end |
#event_map ⇒ Object (readonly)
Returns the value of attribute event_map.
4 5 6 |
# File 'lib/controll/flow/event_mapper/util.rb', line 4 def event_map @event_map end |
Instance Method Details
#map_event ⇒ Object
An event can also be a Symbol, in which case it is a :notice event
19 20 21 22 23 24 |
# File 'lib/controll/flow/event_mapper/util.rb', line 19 def map_event event_map.each do |path, events| return path.to_s if valid? events end raise NoMappingFoundError, "No path could be found for event: #{event.inspect} in map: #{event_map}" end |