Module: GenevaDrive::Workflow::MetadataAccessor Private
- Extended by:
- ActiveSupport::Concern
- Included in:
- GenevaDrive::Workflow
- Defined in:
- lib/geneva_drive/workflow/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 workflows. 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 Workflow.
Instance Method Summary collapse
-
#read_metadata(key) ⇒ Object?
private
Reads a single key from the metadata hash.
-
#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
#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.
48 49 50 51 |
# File 'lib/geneva_drive/workflow/metadata_accessor.rb', line 48 def (key) return nil unless self.class. [key.to_s] 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).
60 61 62 63 64 |
# File 'lib/geneva_drive/workflow/metadata_accessor.rb', line 60 def (key, value) return unless self.class. merged = .merge(key.to_s => value) write_attribute(:metadata, merged.to_json) end |