Class: AcidicJob::WorkflowStep

Inherits:
Object
  • Object
show all
Defined in:
lib/acidic_job/workflow_step.rb

Instance Method Summary collapse

Constructor Details

#initialize(run:, job:) ⇒ WorkflowStep

Returns a new instance of WorkflowStep.



5
6
7
8
# File 'lib/acidic_job/workflow_step.rb', line 5

def initialize(run:, job:)
  @run = run
  @job = job
end

Instance Method Details

#wrappedObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/acidic_job/workflow_step.rb', line 10

def wrapped
  # return a callable Proc with a consistent interface for the execution phase
  proc do |_run|
    current_step_result = process_current_step

    if current_step_result.is_a?(FinishedPoint)
      current_step_result
    elsif next_item.present?
      @run.attr_accessors[iterated_key] = prev_iterateds + [next_item]
      @run.save!(validate: false)
      RecoveryPoint.new(current_step_name)
    elsif @run.next_step_finishes?
      FinishedPoint.new
    else
      RecoveryPoint.new(@run.next_step_name)
    end
  end
end