Class: Signals::BlockListener
- Inherits:
-
Object
- Object
- Signals::BlockListener
- Defined in:
- lib/signals/block_listener.rb
Overview
This is a Listener that once instantiated, will define a method that is named what is passed as the action.
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
Instance Method Summary collapse
- #call(event, *args) ⇒ Object
-
#initialize(event, &block) ⇒ BlockListener
constructor
A new instance of BlockListener.
Constructor Details
#initialize(event, &block) ⇒ BlockListener
Returns a new instance of BlockListener.
8 9 10 11 |
# File 'lib/signals/block_listener.rb', line 8 def initialize(event, &block) @listener = block @event = event end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
6 7 8 |
# File 'lib/signals/block_listener.rb', line 6 def event @event end |
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
6 7 8 |
# File 'lib/signals/block_listener.rb', line 6 def listener @listener end |
Instance Method Details
#call(event, *args) ⇒ Object
13 14 15 16 17 |
# File 'lib/signals/block_listener.rb', line 13 def call(event, *args) if self.event == event self.listener.call(*args) end end |