Class: Igniter::Embed::ExecutionEnvelope

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/embed/execution_envelope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/igniter/embed/execution_envelope.rb', line 6

def errors
  @errors
end

#inputsObject (readonly)

Returns the value of attribute inputs.



6
7
8
# File 'lib/igniter/embed/execution_envelope.rb', line 6

def inputs
  @inputs
end

#metadataObject (readonly)

Returns the value of attribute metadata.



6
7
8
# File 'lib/igniter/embed/execution_envelope.rb', line 6

def 
  @metadata
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/igniter/embed/execution_envelope.rb', line 6

def name
  @name
end

#outputsObject (readonly)

Returns the value of attribute outputs.



6
7
8
# File 'lib/igniter/embed/execution_envelope.rb', line 6

def outputs
  @outputs
end

#resultObject (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

Returns:

  • (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

Returns:

  • (Boolean)


18
19
20
# File 'lib/igniter/embed/execution_envelope.rb', line 18

def success?
  result && errors.empty?
end

#to_hObject



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