Class: Smooth::Event::Relay
Instance Attribute Summary collapse
-
#event_name ⇒ Object
readonly
Returns the value of attribute event_name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#system ⇒ Object
readonly
Returns the value of attribute system.
Instance Method Summary collapse
- #enable ⇒ Object
-
#initialize(event_name, options = {}) ⇒ Relay
constructor
A new instance of Relay.
- #process(event, event_name = nil) ⇒ Object
- #process_and_relay(event, event_name = nil) ⇒ Object
- #relay(_event, _event_name = nil) ⇒ Object
Constructor Details
Instance Attribute Details
#event_name ⇒ Object (readonly)
Returns the value of attribute event_name.
7 8 9 |
# File 'lib/smooth/event/relay.rb', line 7 def event_name @event_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/smooth/event/relay.rb', line 7 def @options end |
#system ⇒ Object (readonly)
Returns the value of attribute system.
7 8 9 |
# File 'lib/smooth/event/relay.rb', line 7 def system @system end |
Instance Method Details
#enable ⇒ Object
28 29 30 |
# File 'lib/smooth/event/relay.rb', line 28 def enable @subscriber ||= system.subscribe_to(event_name, &method(:process_and_relay)) end |
#process(event, event_name = nil) ⇒ Object
24 25 26 |
# File 'lib/smooth/event/relay.rb', line 24 def process(event, event_name = nil) [event, event_name] end |
#process_and_relay(event, event_name = nil) ⇒ Object
32 33 34 35 |
# File 'lib/smooth/event/relay.rb', line 32 def process_and_relay(event, event_name = nil) event, event_name = process(event, event_name) relay(event, event_name) end |
#relay(_event, _event_name = nil) ⇒ Object
19 20 21 22 |
# File 'lib/smooth/event/relay.rb', line 19 def relay(_event, _event_name = nil) # IMPLEMENT IN YOUR OWN CLASS fail NotImplementedError end |