Class: Smith::Workflow::Composite::BranchOutcome

Inherits:
Payload
  • Object
show all
Defined in:
lib/smith/workflow/composite/branch_outcome.rb

Constant Summary

Constants inherited from Payload

Payload::MAX_SERIALIZED_BYTES

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ BranchOutcome

Returns a new instance of BranchOutcome.



93
94
95
96
97
98
99
# File 'lib/smith/workflow/composite/branch_outcome.rb', line 93

def initialize(attributes)
  owned = self.class.normalize_attributes(attributes)
  owned[:output] = self.class.send(:normalize_output, owned[:output])
  super(owned)
  validate_shape!
  validate_digest!
end

Class Method Details

.failed(plan_digest:, branch:, error:, effects:) ⇒ Object



35
36
37
# File 'lib/smith/workflow/composite/branch_outcome.rb', line 35

def failed(plan_digest:, branch:, error:, effects:)
  build(plan_digest:, branch:, effects:, status: :failed, output: nil, error:)
end

.normalize_attributes(attributes) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/smith/workflow/composite/branch_outcome.rb', line 39

def normalize_attributes(attributes)
  normalized = super
  normalize_status!(normalized)
  normalize_error!(normalized)
  normalize_effects!(normalized)
  normalized
end

.succeeded(plan_digest:, branch:, output:, effects:) ⇒ Object



31
32
33
# File 'lib/smith/workflow/composite/branch_outcome.rb', line 31

def succeeded(plan_digest:, branch:, output:, effects:)
  build(plan_digest:, branch:, effects:, status: :succeeded, output:, error: nil)
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


102
# File 'lib/smith/workflow/composite/branch_outcome.rb', line 102

def failed? = status == :failed

#succeeded?Boolean

Returns:

  • (Boolean)


101
# File 'lib/smith/workflow/composite/branch_outcome.rb', line 101

def succeeded? = status == :succeeded