Module: Reform::Form::Sync

Includes:
SyncHash, Writeable
Included in:
Reform::Form
Defined in:
lib/reform/form/sync.rb

Overview

#sync!

1. assign scalars to model (respecting virtual, excluded attributes)
2. call sync! on nested

Defined Under Namespace

Modules: SkipUnchanged, SyncHash, Writeable

Instance Method Summary collapse

Methods included from Writeable

#sync_hash

Methods included from SyncHash

#sync_hash

Instance Method Details

#sync!(options) ⇒ Object

reading from fields allows using readers in form for presentation and writers still pass to fields in #validate????



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/reform/form/sync.rb', line 12

def sync!(options) # semi-public.
  options = Reform::Representer::Options[options.merge(:form => self)] # options local for this form, only.

  input = sync_hash(options)
  # if aliased_model was a proper Twin, we could do changed? stuff there.

  options.delete(:exclude) # TODO: can we use 2 options?

  dynamic_sync_representer.new(aliased_model).from_hash(input, options) # sync properties to Song.

  model
end

#sync_models(options = {}) ⇒ Object Also known as: sync



5
6
7
# File 'lib/reform/form/sync.rb', line 5

def sync_models(options={})
  sync!(options)
end