Class: Roast::Workflow::MetadataManager

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeMetadataManager

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

#metadataObject

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 metadata=(value)
   = if value.is_a?(ActiveSupport::HashWithIndifferentAccess)
    value
  else
    ActiveSupport::HashWithIndifferentAccess.new(value)
  end
  # Reset the wrapper when metadata changes
   = nil
end

#raw_metadataObject

Get the raw metadata hash (for internal use)



30
31
32
# File 'lib/roast/workflow/metadata_manager.rb', line 30

def 
  
end

#to_hObject

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