Added ExtendedDocument.create({}) and #create!({}) so you don't have to do Model.new.create

This commit is contained in:
Matt Aimonetti 2009-07-17 00:12:33 -07:00
parent 964526193b
commit 5140899041
3 changed files with 36 additions and 2 deletions

View file

@ -52,8 +52,25 @@ module CouchRest
end
end
# Defines an instance and save it directly to the database
#
# ==== Returns
# returns the reloaded document
def self.create(options)
instance = new(options)
instance.create
instance
end
# Defines an instance and save it directly to the database
#
# ==== Returns
# returns the reloaded document or raises an exception
def self.create!(options)
instance = new(options)
instance.create!
instance
end
# Automatically set <tt>updated_at</tt> and <tt>created_at</tt> fields
# on the document whenever saving occurs. CouchRest uses a pretty