Class: Smith::Workflow::PreparedStepRecovery

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/smith/workflow/prepared_step_recovery.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ PreparedStepRecovery

Returns a new instance of PreparedStepRecovery.



27
28
29
30
31
32
33
34
35
# File 'lib/smith/workflow/prepared_step_recovery.rb', line 27

def initialize(attributes)
  super
  if dispatch_claim && dispatch_claim.prepared_step.to_h != prepared_step.to_h
    raise ArgumentError, "dispatch claim must belong to the prepared step"
  end

  self.attributes.freeze
  freeze
end

Class Method Details

.not_started(witness) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/smith/workflow/prepared_step_recovery.rb', line 16

def self.not_started(witness)
  case witness
  when PreparedStep
    new(prepared_step: witness, dispatch_claim: nil, execution_status: :not_started)
  when PreparedStepDispatch
    new(prepared_step: witness.prepared_step, dispatch_claim: witness, execution_status: :not_started)
  else
    raise ArgumentError, "recovery witness must be a PreparedStep or PreparedStepDispatch"
  end
end