Class: Lutaml::KeyValue::Adapter::Yamls::Transform

Inherits:
Transform
  • Object
show all
Defined in:
lib/lutaml/key_value/adapter/yamls/transform.rb

Instance Method Summary collapse

Instance Method Details

#data_to_model(data, format, options = {}) ⇒ Object



6
7
8
9
10
11
# File 'lib/lutaml/key_value/adapter/yamls/transform.rb', line 6

def data_to_model(data, format, options = {})
  mappings = defined_mappings_for(:yamls) || mappings_for(:yaml,
                                                          lutaml_register)

  super(data, format, options.merge(mappings: mappings))
end

#model_to_data(instance, _format, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/lutaml/key_value/adapter/yamls/transform.rb', line 13

def model_to_data(instance, _format, options = {})
  # For YAMLS collections, use yamls mappings for this collection
  # But let nested instances use their own yaml mappings
  # by passing :yaml format without forcing mappings parameter
  defined_mappings_for(:yamls) || mappings_for(:yaml, lutaml_register)

  # Override format to :yaml - nested instances will auto-select yaml mappings
  super(instance, :yaml, options)
end