class BusinessFlow::DefaultStepExecutor
Default behavior for running a step queue – execute each step in turn halting the moment something goes wrong. Use the same flow as input and output to all steps.
Attributes
flow[R]
step_queue[R]
Public Class Methods
new(step_queue, flow)
click to toggle source
# File lib/business_flow/default_step_executor.rb, line 6 def initialize(step_queue, flow) @step_queue = step_queue @flow = flow end
Public Instance Methods
call()
click to toggle source
# File lib/business_flow/default_step_executor.rb, line 11 def call @step_queue.each do |step| break if @flow.errors? execute_step(step) end end
Protected Instance Methods
execute_step(step)
click to toggle source
# File lib/business_flow/default_step_executor.rb, line 22 def execute_step(step) catch(:halt_step) do result = step.call(@flow) result.merge_into(@flow) result end end