Sha256: 9b194a3fe56d9e10506bb9fa76a7ffcb1480555fac8412fb7615ba7d9ecf9df1

Contents?: true

Size: 658 Bytes

Versions: 24

Compression:

Stored size: 658 Bytes

Contents

module BusinessFlow
  # 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.
  class DefaultStepExecutor
    def initialize(step_queue, flow)
      @step_queue = step_queue
      @flow = flow
    end

    def call
      @step_queue.each do |step|
        break if @flow.errors?
        execute_step(step)
      end
    end

    protected

    attr_reader :flow, :step_queue

    def execute_step(step)
      catch(:halt_step) do
        result = step.call(@flow)
        result.merge_into(@flow)
        result
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
business_flow-0.17.5 lib/business_flow/default_step_executor.rb
business_flow-0.17.4 lib/business_flow/default_step_executor.rb
business_flow-0.17.3 lib/business_flow/default_step_executor.rb
business_flow-0.17.2 lib/business_flow/default_step_executor.rb
business_flow-0.17.1 lib/business_flow/default_step_executor.rb
business_flow-0.17.0 lib/business_flow/default_step_executor.rb
business_flow-0.16.0 lib/business_flow/default_step_executor.rb
business_flow-0.15.1 lib/business_flow/default_step_executor.rb
business_flow-0.15.0 lib/business_flow/default_step_executor.rb
business_flow-0.14.3 lib/business_flow/default_step_executor.rb
business_flow-0.14.2 lib/business_flow/default_step_executor.rb
business_flow-0.14.1 lib/business_flow/default_step_executor.rb
business_flow-0.14.0 lib/business_flow/default_step_executor.rb
business_flow-0.13.0 lib/business_flow/default_step_executor.rb
business_flow-0.12.1 lib/business_flow/default_step_executor.rb
business_flow-0.12.0 lib/business_flow/default_step_executor.rb
business_flow-0.11.1 lib/business_flow/default_step_executor.rb
business_flow-0.11.0 lib/business_flow/default_step_executor.rb
business_flow-0.10.0 lib/business_flow/default_step_executor.rb
business_flow-0.9.1 lib/business_flow/default_step_executor.rb