Sha256: ddc0812f0a3aaa313a2567d4586f8c9b03cfea60d9a62894741dc0a2a3399d5c
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Noder module Events class EventNode attr_accessor :callback, :next_node def initialize(options={}) @callback = options[:callback] @argument_keys = options[:argument_keys] @has_continued = false raise 'No callback provided' if @callback.nil? end 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 def continue(env=nil) @has_continued = true next_node.call(env || @env) if next_node end protected 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
noder-0.0.2 | lib/noder/events/event_node.rb |