Module: YamlExporter::InstanceMethods
- Defined in:
- lib/yaml_exporter.rb
Instance Method Summary collapse
-
#yaml_export(omit_nil: true) ⇒ Object
omit_nil:(default true) drops keys whose value is empty — a nil attribute, a missingonereference, an absent ownedone, or an emptymanylist. - #yaml_import(yaml_string) ⇒ Object
Instance Method Details
#yaml_export(omit_nil: true) ⇒ Object
omit_nil: (default true) drops keys whose value is empty — a nil
attribute, a missing one reference, an absent owned one, or an empty
many list. Round-trip safe: import treats a missing key, an explicit
null, and an empty list identically. Pass omit_nil: false to keep
explicit nulls in the file (e.g. so optional fields stay discoverable).
52 53 54 55 56 |
# File 'lib/yaml_exporter.rb', line 52 def yaml_export(omit_nil: true) YamlExporter::Exporter.new( self, self.class.yaml_structure_definition, omit_nil: omit_nil ).to_yaml end |
#yaml_import(yaml_string) ⇒ Object
43 44 45 |
# File 'lib/yaml_exporter.rb', line 43 def yaml_import(yaml_string) YamlExporter::Importer.new(self, self.class.yaml_structure_definition).import(yaml_string) end |