Class: Noder::Events::EventNode

Inherits:
Object
  • Object
show all
Defined in:
lib/noder/events/event_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  @callback = options[:callback]
  @argument_keys = options[:argument_keys]
  @has_continued = false
  raise 'No callback provided' if @callback.nil?
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



4
5
6
# File 'lib/noder/events/event_node.rb', line 4

def callback
  @callback
end

#next_nodeObject

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