Class: Smith::Workflow::PreparedStep

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/smith/workflow/prepared_step.rb

Constant Summary collapse

ATTRIBUTES =
%i[
  token transition from persistence_key persistence_version step_number preparation_digest definition_digest
].freeze
DIGEST_PATTERN =
/\A[0-9a-f]{64}\z/
MAX_COUNTER_VALUE =
(2**63) - 1
MAX_ATTRIBUTE_ENTRIES =
16
MAX_SERIALIZED_BYTES =
4 * 1024
UUID_PATTERN =
/\A[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\z/i

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ PreparedStep

Returns a new instance of PreparedStep.



112
113
114
115
116
117
118
119
# File 'lib/smith/workflow/prepared_step.rb', line 112

def initialize(attributes)
  owned = attributes.dup
  digest = owned[:definition_digest] || owned["definition_digest"]
  owned[:definition_digest] = digest.dup.freeze if digest.is_a?(String)
  super(owned)
  self.attributes.freeze
  freeze
end

Class Method Details

.deserialize(value) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/smith/workflow/prepared_step.rb', line 33

def self.deserialize(value)
  attributes = parse_attributes(value)
  normalized = normalize_attributes(attributes)
  validate_attributes!(normalized)
  validate_bounded_values!(normalized)
  new(normalized)
rescue JSON::ParserError, TypeError => e
  raise ArgumentError, "prepared step is invalid: #{e.message}"
end