Class: Stellwerk::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/stellwerk/result.rb

Overview

Represents the result of a flow execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(outputs:, errors:, applied_nodes:, context:) ⇒ Result

Returns a new instance of Result.



8
9
10
11
12
13
# File 'lib/stellwerk/result.rb', line 8

def initialize(outputs:, errors:, applied_nodes:, context:)
  @outputs = outputs || {}
  @errors = errors || []
  @applied_nodes = applied_nodes || []
  @context = context || {}
end

Instance Attribute Details

#applied_nodes ⇒ Object (readonly)

Returns the value of attribute applied_nodes.



6
7
8
# File 'lib/stellwerk/result.rb', line 6

def applied_nodes
  @applied_nodes
end

#context ⇒ Object (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/stellwerk/result.rb', line 6

def context
  @context
end

#errors ⇒ Object (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/stellwerk/result.rb', line 6

def errors
  @errors
end

#outputs ⇒ Object (readonly)

Returns the value of attribute outputs.



6
7
8
# File 'lib/stellwerk/result.rb', line 6

def outputs
  @outputs
end

Instance Method Details

#failure? ⇒ Boolean

Returns true if there were any errors during execution

Returns:

  • (Boolean)


21
22
23
# File 'lib/stellwerk/result.rb', line 21

def failure?
  !success?
end

#success? ⇒ Boolean

Returns true if the flow executed without errors

Returns:

  • (Boolean)


16
17
18
# File 'lib/stellwerk/result.rb', line 16

def success?
  errors.empty?
end

#to_h ⇒ Object

Convert to hash representation



26
27
28
29
30
31
32
33
# File 'lib/stellwerk/result.rb', line 26

def to_h
  {
    outputs: outputs,
    errors: errors,
    applied_nodes: applied_nodes,
    context: context
  }
end