Class: FiniteMachine::Listener
- Inherits:
-
Object
- Object
- FiniteMachine::Listener
- Defined in:
- lib/finite_machine/listener.rb
Overview
A generic listener interface
Instance Method Summary collapse
-
#call(*args) ⇒ Object
(also: #handle_delivery)
private
Invoke event handler.
-
#initialize(*args) ⇒ Listener
constructor
private
Initialize a listener.
-
#on_delivery(&block) ⇒ Object
Define event delivery handler.
Constructor Details
#initialize(*args) ⇒ Listener
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a listener
9 10 11 |
# File 'lib/finite_machine/listener.rb', line 9 def initialize(*args) @name = args.unshift end |
Instance Method Details
#call(*args) ⇒ Object Also known as: handle_delivery
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Invoke event handler
24 25 26 |
# File 'lib/finite_machine/listener.rb', line 24 def call(*args) @on_delivery.call(*args) if @on_delivery end |
#on_delivery(&block) ⇒ Object
Define event delivery handler
16 17 18 19 |
# File 'lib/finite_machine/listener.rb', line 16 def on_delivery(&block) @on_delivery = block self end |