Class: Noder::Events::EMEventNode
- Inherits:
-
Object
- Object
- Noder::Events::EMEventNode
- Defined in:
- lib/noder/events/em_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
-
#initialize(options = {}) ⇒ EMEventNode
constructor
A new instance of EMEventNode.
Constructor Details
#initialize(options = {}) ⇒ EMEventNode
Returns a new instance of EMEventNode.
6 7 8 9 10 |
# File 'lib/noder/events/em_event_node.rb', line 6 def initialize(={}) @callback = [:callback] @argument_keys = [:argument_keys] 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/em_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/em_event_node.rb', line 4 def next_node @next_node end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/noder/events/em_event_node.rb', line 12 def call(env) if callback.respond_to?(:matches_env?) && !callback.matches_env?(env) if next_node operation = proc { next_node.call(env) } EM.defer(operation) end return end operation = proc { call_operation(env) } if next_node callback = proc { |env| next_node.call(env) } EM.defer(operation, callback) else EM.defer(operation) end env end |