Class: Smith::Workflow::Composite::BranchExecution
- Inherits:
-
Payload
- Object
- Dry::Struct
- Payload
- Smith::Workflow::Composite::BranchExecution
show all
- Defined in:
- lib/smith/workflow/composite/branch_execution.rb
Constant Summary
collapse
- VERSION =
1
Constants inherited
from Payload
Payload::MAX_SERIALIZED_BYTES
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BranchExecution.
103
104
105
106
107
|
# File 'lib/smith/workflow/composite/branch_execution.rb', line 103
def initialize(attributes)
owned = self.class.normalize_attributes(attributes)
super(owned)
validate_contract!
end
|
Class Method Details
.build(plan:, branch:) ⇒ Object
41
42
43
44
45
|
# File 'lib/smith/workflow/composite/branch_execution.rb', line 41
def build(plan:, branch:)
validate_plan_branch!(plan, branch)
values = execution_attributes(plan, branch)
new(values.merge(digest: PayloadDigest.call(serializable(values))))
end
|
.normalize_attributes(attributes) ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/smith/workflow/composite/branch_execution.rb', line 47
def normalize_attributes(attributes)
normalized = super
normalize_dispatch!(normalized)
normalize_branch!(normalized)
ENUM_ATTRIBUTES.each { |key| normalized[key] = Enums.normalize(key, normalized[key]) }
normalized
end
|
.serializable(values) ⇒ Object
55
56
57
|
# File 'lib/smith/workflow/composite/branch_execution.rb', line 55
def serializable(values)
values.merge(dispatch: values.fetch(:dispatch).to_h, branch: values.fetch(:branch).to_h)
end
|