Module: Reform::Form::Save
- Included in:
- Reform::Form
- Defined in:
- lib/reform/form/save.rb
Instance Method Summary collapse
-
#save(options = {}, &block) ⇒ Object
Returns the result of that save invocation on the model.
-
#save!(options = {}) ⇒ Object
FIXME.
- #save_model ⇒ Object
- #to_nested_hash ⇒ Object (also: #to_hash)
Instance Method Details
#save(options = {}, &block) ⇒ Object
Returns the result of that save invocation on the model.
3 4 5 6 7 8 9 |
# File 'lib/reform/form/save.rb', line 3 def save(={}, &block) # DISCUSS: we should never hit @mapper here (which writes to the models) when a block is passed. return yield to_nested_hash if block_given? sync_models # recursion save!() end |
#save!(options = {}) ⇒ Object
FIXME.
11 12 13 14 15 16 17 18 19 |
# File 'lib/reform/form/save.rb', line 11 def save!(={}) # FIXME. result = save_model save_representer.new(fields).to_hash # save! on all nested forms. dynamic_save!() result end |
#save_model ⇒ Object
21 22 23 |
# File 'lib/reform/form/save.rb', line 21 def save_model model.save # TODO: implement nested (that should really be done by Twin/AR). end |
#to_nested_hash ⇒ Object Also known as: to_hash
27 28 29 |
# File 'lib/reform/form/save.rb', line 27 def to_nested_hash(*) ActiveSupport::HashWithIndifferentAccess.new(nested_hash_representer.new(fields).to_hash) end |