Class: Roast::Workflow::MetadataManager
- Inherits:
-
Object
- Object
- Roast::Workflow::MetadataManager
- Defined in:
- lib/roast/workflow/metadata_manager.rb
Overview
Manages workflow metadata, providing a structure parallel to output but specifically for internal metadata that shouldn’t be user-facing
Instance Method Summary collapse
-
#from_h(data) ⇒ Object
Restore state from a hash.
-
#initialize ⇒ MetadataManager
constructor
A new instance of MetadataManager.
-
#metadata ⇒ Object
Get metadata wrapped in DotAccessHash for dot notation access.
-
#metadata=(value) ⇒ Object
Set metadata, ensuring it’s always a HashWithIndifferentAccess.
-
#raw_metadata ⇒ Object
Get the raw metadata hash (for internal use).
-
#to_h ⇒ Object
Get a snapshot of the current state for persistence.
Constructor Details
#initialize ⇒ MetadataManager
Returns a new instance of MetadataManager.
8 9 10 11 |
# File 'lib/roast/workflow/metadata_manager.rb', line 8 def initialize = ActiveSupport::HashWithIndifferentAccess.new = nil end |
Instance Method Details
#from_h(data) ⇒ Object
Restore state from a hash
40 41 42 43 44 |
# File 'lib/roast/workflow/metadata_manager.rb', line 40 def from_h(data) return unless data self. = data end |
#metadata ⇒ Object
Get metadata wrapped in DotAccessHash for dot notation access
14 15 16 |
# File 'lib/roast/workflow/metadata_manager.rb', line 14 def ||= DotAccessHash.new() end |
#metadata=(value) ⇒ Object
Set metadata, ensuring it’s always a HashWithIndifferentAccess
19 20 21 22 23 24 25 26 27 |
# File 'lib/roast/workflow/metadata_manager.rb', line 19 def (value) = if value.is_a?(ActiveSupport::HashWithIndifferentAccess) value else ActiveSupport::HashWithIndifferentAccess.new(value) end # Reset the wrapper when metadata changes = nil end |
#raw_metadata ⇒ Object
Get the raw metadata hash (for internal use)
30 31 32 |
# File 'lib/roast/workflow/metadata_manager.rb', line 30 def end |
#to_h ⇒ Object
Get a snapshot of the current state for persistence
35 36 37 |
# File 'lib/roast/workflow/metadata_manager.rb', line 35 def to_h .to_h end |