Module: Disposable::Twin::Property::Struct
- Defined in:
- lib/disposable/twin/property/struct.rb
Overview
Instance Method Summary collapse
- #read_value_for(dfn, options) ⇒ Object
-
#save! ⇒ Object
So far, hashes can’t be persisted separately.
- #sync(options = {}) ⇒ Object (also: #sync!)
-
#sync_hash_representer ⇒ Object
TODO: make this without representable, please.
Instance Method Details
#read_value_for(dfn, options) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/disposable/twin/property/struct.rb', line 7 def read_value_for(dfn, ) name = dfn[:name] # TODO: test sym vs. str. return unless key_value = model.to_h.find { |k, _| k.to_sym == name.to_sym } key_value.last end |
#save! ⇒ Object
So far, hashes can’t be persisted separately.
30 31 |
# File 'lib/disposable/twin/property/struct.rb', line 30 def save! end |
#sync(options = {}) ⇒ Object Also known as: sync!
24 25 26 |
# File 'lib/disposable/twin/property/struct.rb', line 24 def sync(={}) sync_hash_representer.new(self).to_hash end |
#sync_hash_representer ⇒ Object
TODO: make this without representable, please.
14 15 16 17 18 19 20 21 22 |
# File 'lib/disposable/twin/property/struct.rb', line 14 def sync_hash_representer # TODO: make this without representable, please. Sync.hash_representer(self.class) do |dfn| dfn.merge!( prepare: lambda { || [:input] }, serialize: lambda { || [:input].sync! }, representable: true ) if dfn[:nested] end end |