Class: Gaskit::FlowResult

Inherits:
OperationResult show all
Defined in:
lib/gaskit/flow_result.rb

Overview

Represents the result of a flow execution, including step-by-step trace

Examples:

Checking result and accessing steps

result = MyFlow.call(1, 2)
if result.success?
  puts "Total: #{result.value}"
else
  puts "Failed at: #{result.steps.last[:operation]}"
end

Instance Attribute Summary collapse

Attributes inherited from OperationResult

#context, #duration, #error, #success, #value

Instance Method Summary collapse

Methods inherited from OperationResult

#early_exit?, #failure?, #inspect, #status, #success?, #to_json

Constructor Details

#initialize(success, value, error = nil, **options) ⇒ FlowResult

Initializes a new FlowResult .

Parameters:

  • success (Boolean)

    If the flow was successful or not

  • value (Object, nil)

    The final operation result

  • error (StandardError, nil) (defaults to: nil)

    The error encountered during the operation.

  • options (Hash)

    Keyword arguments

Options Hash (**options):

  • :steps (Array<Hash>)

    Step-by-step execution details

  • :duration (Float, String)

    Total flow duration

  • Execution (Hash)

    context



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gaskit/flow_result.rb', line 26

def initialize(success, value, error = nil, **options)
  super(
    success,
    value,
    error,
    duration: options[:duration],
    context: options[:context]
  )

  @steps = options.fetch(:steps, [])
end

Instance Attribute Details

#stepsArray<Hash> (readonly)

Returns A list of step data executed during the flow.

Returns:

  • (Array<Hash>)

    A list of step data executed during the flow



15
16
17
# File 'lib/gaskit/flow_result.rb', line 15

def steps
  @steps
end

Instance Method Details

#to_hObject



38
39
40
# File 'lib/gaskit/flow_result.rb', line 38

def to_h
  super.merge(steps: steps)
end