Module: Flexor::Serialization
- Included in:
- Plugins::Core::StoreMethods
- Defined in:
- lib/flexor/serialization.rb
Overview
Methods for Marshal and YAML round-trip serialization.
Instance Method Summary collapse
- #encode_with(coder) ⇒ Object
- #init_with(coder) ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
Instance Method Details
#encode_with(coder) ⇒ Object
14 15 16 17 |
# File 'lib/flexor/serialization.rb', line 14 def encode_with(coder) coder["store"] = to_h coder["root"] = @root end |
#init_with(coder) ⇒ Object
19 20 21 22 |
# File 'lib/flexor/serialization.rb', line 19 def init_with(coder) @root = coder["root"] @store = vivify(symbolize_keys(coder["store"] || {})) end |
#marshal_dump ⇒ Object
5 6 7 |
# File 'lib/flexor/serialization.rb', line 5 def marshal_dump { store: to_h, root: @root } end |
#marshal_load(data) ⇒ Object
9 10 11 12 |
# File 'lib/flexor/serialization.rb', line 9 def marshal_load(data) @root = data[:root] @store = vivify(data[:store]) end |