Module: Disposable::Twin::Sync::SkipUnchanged
- Defined in:
- lib/disposable/twin/sync.rb
Overview
This will skip unchanged properties in #sync. To use this for all nested form do as follows.
class SongForm < Reform::Form
feature Sync::SkipUnchanged
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
109 110 111 |
# File 'lib/disposable/twin/sync.rb', line 109 def self.included(base) base.send :include, Disposable::Twin::Changed end |
Instance Method Details
#sync_options(options) ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/disposable/twin/sync.rb', line 113 def () # DISCUSS: we currently don't track if nested forms have changed (only their attributes). that's why i include them all here, which # is additional sync work/slightly wrong. solution: allow forms to form.changed? not sure how to do that with collections. scalars = schema.each(scalar: true).collect { |dfn| dfn.name } unchanged = scalars - changed.keys # exclude unchanged scalars, nested forms and changed scalars still go in here! .exclude!(unchanged) super end |