Module: Easyop::Flow::CallBehavior

Defined in:
lib/easyop/flow.rb

Overview

Prepended so that Flow’s ‘call` takes precedence over Operation’s no-op even though Operation is included inside Flow.included (which would otherwise place Operation earlier in the ancestor chain than Flow itself).

Instance Method Summary collapse

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/easyop/flow.rb', line 33

def call
  pending_guard = nil

  self.class._flow_steps.each do |step|
    if step.is_a?(Proc)
      pending_guard = step
      next
    end

    # Evaluate lambda guard if present (placed before step in flow list)
    if pending_guard
      skip = !pending_guard.call(ctx)
      pending_guard = nil
      next if skip
    end

    # Evaluate class-level skip_if predicate declared on the step itself
    next if step.respond_to?(:skip?) && step.skip?(ctx)

    instance = step.new
    instance._easyop_run(ctx, raise_on_failure: true)
    ctx.called!(instance)
  end
rescue Ctx::Failure
  ctx.rollback!
  raise
end