Class: Lutaml::Yamls::Adapter::Transform
- Inherits:
-
KeyValue::Transform
- Object
- Model::Transform
- KeyValue::Transform
- Lutaml::Yamls::Adapter::Transform
- Defined in:
- lib/lutaml/yamls/adapter/transform.rb
Instance Attribute Summary
Attributes inherited from Model::Transform
#attributes, #context, #lutaml_register
Instance Method Summary collapse
- #data_to_model(data, format, options = {}) ⇒ Object
- #model_to_data(instance, _format, options = {}) ⇒ Object
Methods inherited from Model::Transform
data_to_model, #initialize, #model_class, model_to_data
Constructor Details
This class inherits a constructor from Lutaml::Model::Transform
Instance Method Details
#data_to_model(data, format, options = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/lutaml/yamls/adapter/transform.rb', line 7 def data_to_model(data, format, = {}) mappings = defined_mappings_for(:yamls) || mappings_for(:yaml, lutaml_register) super(data, format, .merge(mappings: mappings)) end |
#model_to_data(instance, _format, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/lutaml/yamls/adapter/transform.rb', line 14 def model_to_data(instance, _format, = {}) # 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, ) end |