Module: GenevaDrive::StepExecution::MetadataAccessor Private
- Extended by:
- ActiveSupport::Concern
- Included in:
- GenevaDrive::StepExecution
- Defined in:
- lib/geneva_drive/step_execution/metadata_accessor.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Provides safe read/write access to the freeform JSON metadata column on step executions. All "does the column exist?" logic lives here so the rest of the codebase can call read_metadata / write_metadata without guarding. When the metadata column has not been migrated yet, writes are silent no-ops and reads return nil.
Once the migration becomes mandatory, delete this concern and replace with
a plain attribute :metadata, :json, default: -> { {} } on StepExecution.
Instance Method Summary collapse
-
#exception_info ⇒ Hash?
private
Returns the exception info hash from metadata, if recorded.
-
#read_metadata(key) ⇒ Object?
private
Reads a single key from the metadata hash.
-
#reattempt_reason ⇒ String?
private
Returns the reattempt reason from metadata.
-
#write_metadata(key, value) ⇒ void
private
Merges a key/value pair into the metadata hash (in-memory only, does not persist — call save!/update! separately or include in a broader update).
Instance Method Details
#exception_info ⇒ Hash?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the exception info hash from metadata, if recorded. Keys: "class", "message", "backtrace" (backtrace is an Array of strings).
98 99 100 |
# File 'lib/geneva_drive/step_execution/metadata_accessor.rb', line 98 def exception_info ("exception") end |
#read_metadata(key) ⇒ Object?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Reads a single key from the metadata hash.
68 69 70 71 |
# File 'lib/geneva_drive/step_execution/metadata_accessor.rb', line 68 def (key) return nil unless self.class. [key.to_s] end |
#reattempt_reason ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the reattempt reason from metadata. Possible values: "flow_control", "exception_policy", "precondition", or nil.
90 91 92 |
# File 'lib/geneva_drive/step_execution/metadata_accessor.rb', line 90 def reattempt_reason ("reattempt_reason") end |
#write_metadata(key, value) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Merges a key/value pair into the metadata hash (in-memory only, does not persist — call save!/update! separately or include in a broader update).
80 81 82 83 84 |
# File 'lib/geneva_drive/step_execution/metadata_accessor.rb', line 80 def (key, value) return unless self.class. merged = .merge(key.to_s => value) write_attribute(:metadata, merged.to_json) end |