Class: Igniter::Embed::ExecutionEnvelope
- Inherits:
-
Object
- Object
- Igniter::Embed::ExecutionEnvelope
- Defined in:
- lib/igniter/embed/execution_envelope.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(name:, inputs:, result: nil, errors: nil, metadata: {}) ⇒ ExecutionEnvelope
constructor
A new instance of ExecutionEnvelope.
- #output(name) ⇒ Object
- #success? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(name:, inputs:, result: nil, errors: nil, metadata: {}) ⇒ ExecutionEnvelope
Returns a new instance of ExecutionEnvelope.
8 9 10 11 12 13 14 15 16 |
# File 'lib/igniter/embed/execution_envelope.rb', line 8 def initialize(name:, inputs:, result: nil, errors: nil, metadata: {}) @name = name.to_sym @inputs = inputs.freeze @result = result @outputs = result ? result.outputs : Igniter::Contracts::NamedValues.new({}) @errors = Array(errors).freeze @metadata = .freeze freeze end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/igniter/embed/execution_envelope.rb', line 6 def errors @errors end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
6 7 8 |
# File 'lib/igniter/embed/execution_envelope.rb', line 6 def inputs @inputs end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/igniter/embed/execution_envelope.rb', line 6 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/igniter/embed/execution_envelope.rb', line 6 def name @name end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
6 7 8 |
# File 'lib/igniter/embed/execution_envelope.rb', line 6 def outputs @outputs end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
6 7 8 |
# File 'lib/igniter/embed/execution_envelope.rb', line 6 def result @result end |
Instance Method Details
#failure? ⇒ Boolean
22 23 24 |
# File 'lib/igniter/embed/execution_envelope.rb', line 22 def failure? !success? end |
#output(name) ⇒ Object
26 27 28 |
# File 'lib/igniter/embed/execution_envelope.rb', line 26 def output(name) outputs.fetch(name.to_sym) end |
#success? ⇒ Boolean
18 19 20 |
# File 'lib/igniter/embed/execution_envelope.rb', line 18 def success? result && errors.empty? end |
#to_h ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/igniter/embed/execution_envelope.rb', line 30 def to_h { name: name, inputs: inputs, success: success?, outputs: outputs.to_h, errors: errors.map { |error| normalize_error(error) }, metadata: } end |