module Disposable::Twin::Save

Public Instance Methods

save(options={}, &block) click to toggle source

Returns the result of that save invocation on the model.

# File lib/disposable/twin/save.rb, line 4
def save(options={}, &block)
  res = sync(&block)
  return res if block_given?

  save!(options)
end
save!(options={}) click to toggle source
# File lib/disposable/twin/save.rb, line 11
def save!(options={})
  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() click to toggle source
# File lib/disposable/twin/save.rb, line 24
def save_model
  model.save
end