Class: Lutaml::Store::Format::MarshalFormat
- Defined in:
- lib/lutaml/store/format/marshal_format.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
20 21 22 23 |
# File 'lib/lutaml/store/format/marshal_format.rb', line 20 def deserialize(data, model_class) hash_data = ::Marshal.load(data) model_class.from_hash(hash_data) end |
#deserialize_many(data, model_class) ⇒ Object
30 31 32 33 |
# File 'lib/lutaml/store/format/marshal_format.rb', line 30 def deserialize_many(data, model_class) hash_array = ::Marshal.load(data) hash_array.map { |h| model_class.from_hash(h) } end |
#extension ⇒ Object
7 8 9 |
# File 'lib/lutaml/store/format/marshal_format.rb', line 7 def extension ".bin" end |
#glob_pattern ⇒ Object
11 12 13 |
# File 'lib/lutaml/store/format/marshal_format.rb', line 11 def glob_pattern "*.bin" end |
#serialize(model) ⇒ Object
15 16 17 18 |
# File 'lib/lutaml/store/format/marshal_format.rb', line 15 def serialize(model) hash_data = model.to_hash ::Marshal.dump(hash_data) end |
#serialize_many(models) ⇒ Object
25 26 27 28 |
# File 'lib/lutaml/store/format/marshal_format.rb', line 25 def serialize_many(models) hash_array = models.map(&:to_hash) ::Marshal.dump(hash_array) end |