Sha256: 2e6b92d0f0dc269e8bfa8fe05b201afd664ac8112654fdc7ace7eab3fd345030
Contents?: true
Size: 759 Bytes
Versions: 1
Compression:
Stored size: 759 Bytes
Contents
module Disposable class Twin # Twin that uses a hash to populate. # # Twin.new(id: 1) module Struct def read_value_for(dfn, options) name = dfn[:name] @model[name.to_s] || @model[name.to_sym] # TODO: test sym vs. str. end def sync_hash_representer # TODO: make this without representable, please. Sync.hash_representer(self.class) do |dfn| dfn.merge!( prepare: lambda { |model, *| model }, serialize: lambda { |model, *| model.sync! }, representable: true ) if dfn[:nested] end end def sync(options={}) sync_hash_representer.new(self).to_hash end alias_method :sync!, :sync end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
disposable-0.2.0.rc1 | lib/disposable/twin/struct.rb |