Class: Lutaml::Model::Yaml::StandardAdapter

Inherits:
Document show all
Defined in:
lib/lutaml/model/yaml/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 KeyValueDocument

#attributes, #register

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from KeyValueDocument

#[], #[]=, #initialize, #key?, #to_h

Constructor Details

This class inherits a constructor from Lutaml::Model::KeyValueDocument

Class Method Details

.parse(yaml, _options = {}) ⇒ Object



18
19
20
# File 'lib/lutaml/model/yaml/standard_adapter.rb', line 18

def self.parse(yaml, _options = {})
  YAML.safe_load(yaml, permitted_classes: PERMITTED_CLASSES)
end

Instance Method Details

#to_yaml(options = {}) ⇒ Object



22
23
24
# File 'lib/lutaml/model/yaml/standard_adapter.rb', line 22

def to_yaml(options = {})
  YAML.dump(@attributes, options)
end