Class: Lutaml::Yaml::Adapter::StandardAdapter
- Inherits:
-
Document
- Object
- KeyValue::Document
- Document
- Lutaml::Yaml::Adapter::StandardAdapter
- Defined in:
- lib/lutaml/yaml/adapter/standard_adapter.rb
Constant Summary collapse
- FORMAT_SYMBOL =
:yaml- PERMITTED_CLASSES_BASE =
[Date, Time, DateTime, Symbol, ::Hash, Array].freeze
- PERMITTED_CLASSES =
if defined?(BigDecimal) PERMITTED_CLASSES_BASE + [BigDecimal] else PERMITTED_CLASSES_BASE end.freeze
Instance Attribute Summary
Attributes inherited from KeyValue::Document
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from KeyValue::Document
#[], #[]=, #initialize, #key?, #to_h
Constructor Details
This class inherits a constructor from Lutaml::KeyValue::Document
Class Method Details
.parse(yaml, _options = {}) ⇒ Object
20 21 22 |
# File 'lib/lutaml/yaml/adapter/standard_adapter.rb', line 20 def self.parse(yaml, = {}) YAML.safe_load(yaml, permitted_classes: PERMITTED_CLASSES) end |
Instance Method Details
#to_yaml(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lutaml/yaml/adapter/standard_adapter.rb', line 24 def to_yaml( = {}) # Handle KeyValueElement input (new symmetric architecture) attributes_to_serialize = if @attributes.is_a?(Lutaml::KeyValue::DataModel::Element) # Unwrap __root__ wrapper to get actual content @attributes.to_hash["__root__"] else # Legacy Hash input (backward compatibility) @attributes end YAML.dump(attributes_to_serialize, ) end |