Whitespaces.
This commit is contained in:
parent
608869be45
commit
6b66e7f23e
|
@ -3,7 +3,7 @@ module CouchRest
|
||||||
module Persistence
|
module Persistence
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
# Create the document. Validation is enabled by default and will return
|
# Create the document. Validation is enabled by default and will return
|
||||||
# false if the document is not valid. If all goes well, the document will
|
# false if the document is not valid. If all goes well, the document will
|
||||||
# be returned.
|
# be returned.
|
||||||
def create(options = {})
|
def create(options = {})
|
||||||
|
@ -16,13 +16,13 @@ module CouchRest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates the document in the db. Raises an exception
|
# Creates the document in the db. Raises an exception
|
||||||
# if the document is not created properly.
|
# if the document is not created properly.
|
||||||
def create!
|
def create!
|
||||||
self.class.fail_validate!(self) unless self.create
|
self.class.fail_validate!(self) unless self.create
|
||||||
end
|
end
|
||||||
|
|
||||||
# Trigger the callbacks (before, after, around)
|
# Trigger the callbacks (before, after, around)
|
||||||
# only if the document isn't new
|
# only if the document isn't new
|
||||||
def update(options = {})
|
def update(options = {})
|
||||||
|
@ -35,12 +35,12 @@ module CouchRest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Trigger the callbacks (before, after, around) and save the document
|
# Trigger the callbacks (before, after, around) and save the document
|
||||||
def save(options = {})
|
def save(options = {})
|
||||||
self.new? ? create(options) : update(options)
|
self.new? ? create(options) : update(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Saves the document to the db using save. Raises an exception
|
# Saves the document to the db using save. Raises an exception
|
||||||
# if the document is not saved properly.
|
# if the document is not saved properly.
|
||||||
def save!
|
def save!
|
||||||
|
@ -65,7 +65,7 @@ module CouchRest
|
||||||
# Update the document's attributes and save. For example:
|
# Update the document's attributes and save. For example:
|
||||||
#
|
#
|
||||||
# doc.update_attributes :name => "Fred"
|
# doc.update_attributes :name => "Fred"
|
||||||
# Is the equivalent of doing the following:
|
# Is the equivilent of doing the following:
|
||||||
#
|
#
|
||||||
# doc.attributes = { :name => "Fred" }
|
# doc.attributes = { :name => "Fred" }
|
||||||
# doc.save
|
# doc.save
|
||||||
|
@ -107,11 +107,11 @@ module CouchRest
|
||||||
# a document instance
|
# a document instance
|
||||||
def create_from_database(doc = {})
|
def create_from_database(doc = {})
|
||||||
base = (doc[model_type_key].blank? || doc[model_type_key] == self.to_s) ? self : doc[model_type_key].constantize
|
base = (doc[model_type_key].blank? || doc[model_type_key] == self.to_s) ? self : doc[model_type_key].constantize
|
||||||
base.new(doc, :directly_set_attributes => true)
|
base.new(doc, :directly_set_attributes => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Defines an instance and save it directly to the database
|
# Defines an instance and save it directly to the database
|
||||||
#
|
#
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# returns the reloaded document
|
# returns the reloaded document
|
||||||
def create(attributes = {})
|
def create(attributes = {})
|
||||||
|
@ -119,9 +119,9 @@ module CouchRest
|
||||||
instance.create
|
instance.create
|
||||||
instance
|
instance
|
||||||
end
|
end
|
||||||
|
|
||||||
# Defines an instance and save it directly to the database
|
# Defines an instance and save it directly to the database
|
||||||
#
|
#
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# returns the reloaded document or raises an exception
|
# returns the reloaded document or raises an exception
|
||||||
def create!(attributes = {})
|
def create!(attributes = {})
|
||||||
|
@ -157,7 +157,7 @@ module CouchRest
|
||||||
raise Errors::Validations.new(document)
|
raise Errors::Validations.new(document)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue