Class: Noder::Events::EventNode
- Inherits:
-
Object
- Object
- Noder::Events::EventNode
- Defined in:
- lib/noder/events/event_node.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#next_node ⇒ Object
Returns the value of attribute next_node.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #continue(env = nil) ⇒ Object
-
#initialize(options = {}) ⇒ EventNode
constructor
A new instance of EventNode.
Constructor Details
#initialize(options = {}) ⇒ EventNode
Returns a new instance of EventNode.
6 7 8 9 10 11 |
# File 'lib/noder/events/event_node.rb', line 6 def initialize(={}) @callback = [:callback] @argument_keys = [:argument_keys] @has_continued = false raise 'No callback provided' if @callback.nil? end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
4 5 6 |
# File 'lib/noder/events/event_node.rb', line 4 def callback @callback end |
#next_node ⇒ Object
Returns the value of attribute next_node.
4 5 6 |
# File 'lib/noder/events/event_node.rb', line 4 def next_node @next_node end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/noder/events/event_node.rb', line 13 def call(env) @env = env if @argument_keys arguments = Utils.slice_hash(@env, @argument_keys).values else arguments = [@env] end perform_callback(arguments) continue unless @has_continued end |
#continue(env = nil) ⇒ Object
24 25 26 27 |
# File 'lib/noder/events/event_node.rb', line 24 def continue(env=nil) @has_continued = true next_node.call(env || @env) if next_node end |