Module: Disposable::Twin::Sync::ToNestedHash::ClassMethods
- Defined in:
- lib/disposable/twin/sync.rb
Instance Method Summary collapse
- #build_nested_hash_representer ⇒ Object
-
#nested_hash_representer ⇒ Object
Create a hash representer on-the-fly to serialize the form to a hash.
Instance Method Details
#build_nested_hash_representer ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/disposable/twin/sync.rb', line 90 def build_nested_hash_representer Sync.hash_representer(self) do |dfn| dfn.merge!( readable: true, # the nested hash contains all fields. as: dfn[:private_name], # nested hash keys by model property names. render_nil: dfn[:collection] ? nil : true, ) dfn.merge!( prepare: lambda { || [:input] }, # TODO: why do we need that here? serialize: lambda { || [:input].to_nested_hash }, ) if dfn[:nested] end end |
#nested_hash_representer ⇒ Object
Create a hash representer on-the-fly to serialize the form to a hash.
86 87 88 |
# File 'lib/disposable/twin/sync.rb', line 86 def nested_hash_representer @nested_hash_representer ||= build_nested_hash_representer end |