class Ni::ActionChain
Attributes
description[RW]
failure_callback[RW]
name[RW]
received_values[RW]
rescues[RW]
returned_values[RW]
units[RW]
Public Class Methods
new(klass, name, description, &block)
click to toggle source
# File lib/ni/action_chain.rb, line 5 def initialize(klass, name, description, &block) @interactor_klass = klass @name = name, @description = description @units = block_given? ? [block.to_proc] : [] @failure_callback = nil @rescues = [] @returned_values = [] self ensure update_chain end
Public Instance Methods
branch(*args, **options, &block)
click to toggle source
# File lib/ni/action_chain.rb, line 89 def branch(*args, **options, &block) @units << Ni::Flows::BranchInteractor.new(@interactor_klass, args, options, &block) self ensure update_chain end
cancel!()
click to toggle source
# File lib/ni/action_chain.rb, line 103 def cancel! @units << "context.cancel!" ensure update_chain end
failure(&block)
click to toggle source
# File lib/ni/action_chain.rb, line 63 def failure(&block) @failure_callback = block.to_proc self ensure update_chain end
failure!()
click to toggle source
# File lib/ni/action_chain.rb, line 109 def failure! @units << "context.failure!" ensure update_chain end
isolate(*args, **options, &block)
click to toggle source
# File lib/ni/action_chain.rb, line 50 def isolate(*args, **options, &block) if block_given? raise 'Not Implemented yet' else first, last = args @units << Ni::Flows::IsolatedInlineInteractor.new(first, (last || :perform), options) end self ensure update_chain end
provide(*args)
click to toggle source
# File lib/ni/action_chain.rb, line 28 def provide(*args) @returned_values = args self ensure update_chain end
receive(*args)
click to toggle source
Params
methods
# File lib/ni/action_chain.rb, line 20 def receive(*args) @received_values = args self ensure update_chain end
rescue_from(*args, &block)
click to toggle source
# File lib/ni/action_chain.rb, line 71 def rescue_from(*args, &block) args = [Exception] if args.empty? @rescues << [args, block.to_proc] self ensure update_chain end
success!()
click to toggle source
# File lib/ni/action_chain.rb, line 115 def success! @units << "context.success!" ensure update_chain end
terminate!()
click to toggle source
# File lib/ni/action_chain.rb, line 97 def terminate! @units << "context.terminate!" ensure update_chain end
then(*args, **options, &block)
click to toggle source
Flow methods
# File lib/ni/action_chain.rb, line 38 def then(*args, **options, &block) if block_given? @units << block.to_proc else @units << chain_builder(args, options) end self ensure update_chain end
wait_for(condition, options={})
click to toggle source
# File lib/ni/action_chain.rb, line 81 def wait_for(condition, options={}) @units << Ni::Flows::WaitForCondition.new(condition, @interactor_klass, options) self ensure update_chain end
Private Instance Methods
chain_builder(args, options)
click to toggle source
# File lib/ni/action_chain.rb, line 123 def chain_builder(args, options) first, last = args case first when Symbol, String first when Class Ni::Flows::InlineInteractor.new(first, (last || :perform), options) else raise 'Invalid chain options' end end
update_chain()
click to toggle source
# File lib/ni/action_chain.rb, line 136 def update_chain @interactor_klass.defined_actions[name] = self end