Class: Lutaml::Lml::TopElementAttribute
- Inherits:
-
Model::Serializable
- Object
- Model::Serializable
- Lutaml::Lml::TopElementAttribute
- Defined in:
- lib/lutaml/lml/models/top_element_attribute.rb
Instance Method Summary collapse
-
#value_from(model, value) ⇒ Object
lutaml-model runs this on a throwaway mapper instance, so
selfis not the object being deserialized -modelis. -
#value_to(model, doc) ⇒ Object
Public because lutaml-model invokes mapping methods via public_send.
Instance Method Details
#value_from(model, value) ⇒ Object
lutaml-model runs this on a throwaway mapper instance, so self is not
the object being deserialized - model is. Writing to self.value
here would update an object that is discarded a moment later.
78 79 80 |
# File 'lib/lutaml/lml/models/top_element_attribute.rb', line 78 def value_from(model, value) model.value = value end |
#value_to(model, doc) ⇒ Object
Public because lutaml-model invokes mapping methods via public_send.
Skipping nil keeps the key out of the output, which is what the default
mapping does. false is a real literal, so the guard tests for nil
rather than truthiness.
68 69 70 71 72 73 |
# File 'lib/lutaml/lml/models/top_element_attribute.rb', line 68 def value_to(model, doc) literal = model.value return if literal.nil? doc["value"] = unwrap_literal(literal) end |