Class: Smith::Workflow::SplitStepPersistence::ExecutionWorkflowSnapshot

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/smith/workflow/split_step_persistence/execution_workflow_snapshot.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.capture(workflow_class) ⇒ Object



17
18
19
# File 'lib/smith/workflow/split_step_persistence/execution_workflow_snapshot.rb', line 17

def self.capture(workflow_class, &)
  new(workflow_class).capture(&)
end

Instance Method Details

#captureObject



21
22
23
24
25
26
27
28
# File 'lib/smith/workflow/split_step_persistence/execution_workflow_snapshot.rb', line 21

def capture
  @initial_state_signature = initial_state_signature
  @transitions = reachable_definition_transitions.map do |transition|
    yield transition if block_given?
    [transition.name, transition, TransitionContract.capture(transition)].freeze
  end.freeze
  freeze
end

#verify!Object

Raises:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/smith/workflow/split_step_persistence/execution_workflow_snapshot.rb', line 30

def verify!
  unless initial_state_signature == @initial_state_signature
    raise WorkflowError, "authorized nested workflow definition changed before execution"
  end

  index = 0
  reachable_definition_transitions.each do |transition|
    expected = @transitions[index]
    verify_transition!(transition, expected)
    index += 1
  end
  return true if index == @transitions.length

  raise WorkflowError, "authorized nested workflow definition changed before execution"
end