Module: Disposable::Twin::Save
- Defined in:
- lib/disposable/twin/save.rb
Instance Method Summary collapse
-
#save(options = {}, &block) ⇒ Object
Returns the result of that save invocation on the model.
- #save!(options = {}) ⇒ Object
- #save_model ⇒ Object
Instance Method Details
#save(options = {}, &block) ⇒ Object
Returns the result of that save invocation on the model.
4 5 6 7 8 9 |
# File 'lib/disposable/twin/save.rb', line 4 def save(={}, &block) res = sync(&block) return res if block_given? save!() end |
#save!(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/disposable/twin/save.rb', line 11 def save!(={}) result = save_model schema.each(twin: true) do |dfn| next if dfn[:save] == false # call #save! on all nested twins. PropertyProcessor.new(dfn, self).() { |twin| twin.save! } end result end |
#save_model ⇒ Object
24 25 26 |
# File 'lib/disposable/twin/save.rb', line 24 def save_model model.save end |