Class: Lutaml::Store::Format::Yamls
- Defined in:
- lib/lutaml/store/format/yamls.rb
Instance Method Summary collapse
- #deserialize(data, model_class) ⇒ Object
- #deserialize_many(data, model_class) ⇒ Object
- #extension ⇒ Object
- #glob_pattern ⇒ Object
- #serialize(model) ⇒ Object
- #serialize_many(models) ⇒ Object
Instance Method Details
#deserialize(data, model_class) ⇒ Object
23 24 25 26 |
# File 'lib/lutaml/store/format/yamls.rb', line 23 def deserialize(data, model_class) docs = model_class.from_yamls(data) docs.is_a?(Array) ? docs.first : docs end |
#deserialize_many(data, model_class) ⇒ Object
28 29 30 31 |
# File 'lib/lutaml/store/format/yamls.rb', line 28 def deserialize_many(data, model_class) result = model_class.from_yamls(data) result.is_a?(Array) ? result : [result] end |
#extension ⇒ Object
7 8 9 |
# File 'lib/lutaml/store/format/yamls.rb', line 7 def extension ".yaml" end |
#glob_pattern ⇒ Object
11 12 13 |
# File 'lib/lutaml/store/format/yamls.rb', line 11 def glob_pattern "*.{yaml,yml}" end |
#serialize(model) ⇒ Object
15 16 17 |
# File 'lib/lutaml/store/format/yamls.rb', line 15 def serialize(model) model.to_yaml end |
#serialize_many(models) ⇒ Object
19 20 21 |
# File 'lib/lutaml/store/format/yamls.rb', line 19 def serialize_many(models) models.map(&:to_yaml).join end |