Class: Smith::Workflow::FailureRecordText
- Inherits:
-
Object
- Object
- Smith::Workflow::FailureRecordText
- Extended by:
- Dry::Initializer
- Defined in:
- lib/smith/workflow/failure_record_text.rb
Constant Summary collapse
- MISSING_TEXT =
Deterministic stand-in shared by capture and restore for failure messages that would otherwise be blank.
"failure message unavailable"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.capture(value, limit:, label:, normalize_length: false) ⇒ Object
31 32 33 |
# File 'lib/smith/workflow/failure_record_text.rb', line 31 def self.capture(value, limit:, label:, normalize_length: false) new(value, limit:, label:, normalize_length:).call end |
Instance Method Details
#call ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/smith/workflow/failure_record_text.rb', line 35 def call text = owned_text validate_encoding!(text) size = STRING_BYTESIZE.bind_call(text) return normalized(text, size) if normalize_length raise PersistedFailureInvalid, "persisted workflow failure #{label} is invalid" unless size.between?(1, limit) text.freeze end |