class Noder::Events::EventNode
Attributes
callback[RW]
next_node[RW]
Public Class Methods
new(options={})
click to toggle source
# 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
Public Instance Methods
call(env)
click to toggle source
# 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)
click to toggle source
# 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
Protected Instance Methods
perform_callback(arguments)
click to toggle source
# File lib/noder/events/event_node.rb, line 31 def perform_callback(arguments) continue_method = method(:continue) if @callback.is_a?(Proc) @callback.call(*arguments, continue_method) elsif @callback.is_a?(Class) @env = @callback.new(continue_method).call(*arguments) else @env = @callback.call(*arguments, continue_method) end end