module Mongoid::Persistable::Savable

def save(options = {})

Other tags:
    Since: - 1.0.0

Returns:
  • (true, false) - True is success, false if not.

Parameters:
  • options (Hash) -- Options to pass to the save.

Other tags:
    Example: Save the document. -
def save(options = {})
  if new_record?
    !insert(options).new_record?
  else
    update_document(options)
  end
end

def save!(options = {})

Other tags:
    Since: - 1.0.0

Returns:
  • (true, false) - True if validation passed.

Raises:
  • (Errors::Callback) - If a callback returns false.
  • (Errors::Validations) - If validation failed.

Parameters:
  • options (Hash) -- Options to pass to the save.

Other tags:
    Example: Save the document. -
def save!(options = {})
  unless save(options)
    fail_due_to_validation! unless errors.empty?
    fail_due_to_callback!(:save!)
  end
  true
end