Class: Smith::Workflow::Composite::Branch

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

Constant Summary collapse

MAX_BUDGET_DIMENSIONS =
128

Constants inherited from Payload

Payload::MAX_SERIALIZED_BYTES

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Branch

Returns a new instance of Branch.

Raises:

  • (ArgumentError)


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

def initialize(attributes)
  owned = self.class.normalize_attributes(attributes)
  owned[:budget] = self.class.send(:normalize_budget, owned[:budget])
  super(owned)
  expected = PayloadDigest.call(to_h.except(:digest))
  raise ArgumentError, "composite branch digest does not match" unless digest == expected
end

Class Method Details

.build(ordinal:, key:, agent:, binding_identity:, budget:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/smith/workflow/composite/branch.rb', line 27

def self.build(ordinal:, key:, agent:, binding_identity:, budget:)
  attributes = {
    ordinal:,
    key: key.to_s,
    agent: agent.to_s,
    binding_identity:,
    budget: normalize_budget(budget)
  }
  new(attributes.merge(digest: PayloadDigest.call(attributes)))
end