Class: Pallets::Serializers::Base
- Inherits:
-
Object
- Object
- Pallets::Serializers::Base
- Defined in:
- lib/pallets/serializers/base.rb
Instance Method Summary collapse
- #dump(data) ⇒ Object (also: #dump_job)
-
#dump_context(data) ⇒ Object
Context hashes only need their values (de)serialized.
- #load(data) ⇒ Object (also: #load_job)
- #load_context(data) ⇒ Object
Instance Method Details
#dump(data) ⇒ Object Also known as: dump_job
4 5 6 |
# File 'lib/pallets/serializers/base.rb', line 4 def dump(data) raise NotImplementedError end |
#dump_context(data) ⇒ Object
Context hashes only need their values (de)serialized
16 17 18 |
# File 'lib/pallets/serializers/base.rb', line 16 def dump_context(data) data.map { |k, v| [k.to_s, dump(v)] }.to_h end |
#load(data) ⇒ Object Also known as: load_job
8 9 10 |
# File 'lib/pallets/serializers/base.rb', line 8 def load(data) raise NotImplementedError end |
#load_context(data) ⇒ Object
20 21 22 |
# File 'lib/pallets/serializers/base.rb', line 20 def load_context(data) data.map { |k, v| [k, load(v)] }.to_h end |