Class: Smith::Workflow::PreparedStepExecutionResult

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ PreparedStepExecutionResult

Returns a new instance of PreparedStepExecutionResult.



20
21
22
23
24
25
26
27
# File 'lib/smith/workflow/prepared_step_execution_result.rb', line 20

def initialize(attributes)
  owned = attributes.dup
  owned[:step] = snapshot(owned.fetch(:step), freeze_copy: true, preserved_error: owned[:error])
  super(owned)
  validate_shape!
  self.attributes.freeze
  freeze
end

Class Method Details

.from_step(step) ⇒ Object



15
16
17
18
# File 'lib/smith/workflow/prepared_step_execution_result.rb', line 15

def self.from_step(step)
  error = step[:error]
  new(status: error ? :failed : :succeeded, step:, error:)
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


30
# File 'lib/smith/workflow/prepared_step_execution_result.rb', line 30

def failed? = status == :failed

#step_snapshotObject



31
# File 'lib/smith/workflow/prepared_step_execution_result.rb', line 31

def step_snapshot = snapshot(step, freeze_copy: false, preserved_error: error)

#succeeded?Boolean

Returns:

  • (Boolean)


29
# File 'lib/smith/workflow/prepared_step_execution_result.rb', line 29

def succeeded? = status == :succeeded