Class: Frigate::Form::Synchronizer::Basic
- Inherits:
-
Base
- Object
- Fundamental
- Base
- Frigate::Form::Synchronizer::Basic
- Defined in:
- lib/frigate/form/synchronizer/basic.rb
Overview
A syncronizator between form properties and model properties
Defined Under Namespace
Classes: ModelSynchronizer
Instance Attribute Summary
Attributes inherited from Fundamental
Instance Method Summary collapse
-
#sync_errors ⇒ Boolean
Synchronizes properties errors with form errors.
- #sync_properties_with_model_or_params ⇒ Object
-
#sync_with_model(opts = {}) ⇒ Boolean
Synchronizes given params with given model.
Methods inherited from Fundamental
Constructor Details
This class inherits a constructor from Frigate::Form::Synchronizer::Fundamental
Instance Method Details
#sync_errors ⇒ Boolean
Synchronizes properties errors with form errors
60 61 62 63 64 65 66 67 |
# File 'lib/frigate/form/synchronizer/basic.rb', line 60 def sync_errors form.properties.each { |_prop| form.errors.add(_prop.name, _prop.errors[:value]) unless _prop.valid? } form.associations.each do |_assoc| _assoc.properties.each do |_prop| form.errors.add("#{_assoc.name}.#{_prop.name}", _prop.errors[:value]) unless _prop.valid? end end end |
#sync_properties_with_model_or_params ⇒ Object
69 70 71 |
# File 'lib/frigate/form/synchronizer/basic.rb', line 69 def sync_properties_with_model_or_params raise NotImplementedError end |
#sync_with_model(opts = {}) ⇒ Boolean
Synchronizes given params with given model
54 55 56 |
# File 'lib/frigate/form/synchronizer/basic.rb', line 54 def sync_with_model(opts={}) ModelSynchronizer.new(form).sync_with_model(opts) end |