module Disposable::Twin::Property::Struct
Twin
that uses a hash to populate.
Twin.new(id: 1)
Public Instance Methods
read_value_for(dfn, options)
click to toggle source
# File lib/disposable/twin/property/struct.rb, line 7 def read_value_for(dfn, options) 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!()
click to toggle source
So far, hashes can’t be persisted separately.
# File lib/disposable/twin/property/struct.rb, line 30 def save! end
sync(options={})
click to toggle source
# File lib/disposable/twin/property/struct.rb, line 24 def sync(options={}) sync_hash_representer.new(self).to_hash end
Also aliased as: sync!
sync_hash_representer()
click to toggle source
# 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 { |options| options[:input] }, serialize: lambda { |options| options[:input].sync! }, representable: true ) if dfn[:nested] end end