Module: Reform::Form::Sync::Writer

Defined in:
lib/reform/form/sync.rb

Overview

Mechanics for writing input to model. Writes input to model.

Instance Method Summary collapse

Instance Method Details

#from_hashObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/reform/form/sync.rb', line 8

def from_hash(*)
  # process output from InputRepresenter {title: "Mint Car", hit: <Form>}
  # and just call sync! on nested forms.
  nested_forms do |attr|
    attr.merge!(
      :instance     => lambda { |fragment, *| fragment },
      :deserialize => lambda { |object, *| model = object.sync! } # sync! returns the synced model.
      # representable's :setter will do collection=([..]) or property=(..) for us on the model.
    )
  end

  super
end