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, *| object.sync! },
      :setter => lambda { |*| } # don't write hit=<Form>.
    )
  end

  super
end