Class: Lutaml::KeyValue::Adapter::Jsonl::Transform
- Inherits:
-
Transform
- Object
- Model::Transform
- Transform
- Lutaml::KeyValue::Adapter::Jsonl::Transform
- Defined in:
- lib/lutaml/key_value/adapter/jsonl/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
6 7 8 9 10 11 |
# File 'lib/lutaml/key_value/adapter/jsonl/transform.rb', line 6 def data_to_model(data, format, = {}) mappings = defined_mappings_for(:jsonl) || mappings_for(:json, lutaml_register) super(data, format, .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/jsonl/transform.rb', line 13 def model_to_data(instance, _format, = {}) # For JSONL collections, use jsonl mappings for this collection # But let nested instances use their own json mapping # by passing :json format without forcing mappings parameter defined_mappings_for(:jsonl) || mappings_for(:json, lutaml_register) # Override format to :json - nested instances will auto-select json mappings super(instance, :json, ) end |