Destroy method now freezes instead of removing ids

This commit is contained in:
Sam Lown 2011-06-05 11:21:01 +02:00
parent d56179aa6b
commit 36157a01d3
3 changed files with 27 additions and 13 deletions

View file

@ -54,19 +54,21 @@ module CouchRest
end
# Deletes the document from the database. Runs the :destroy callbacks.
# Removes the <tt>_id</tt> and <tt>_rev</tt> fields, preparing the
# document to be saved to a new <tt>_id</tt> if required.
def destroy
_run_destroy_callbacks do
result = database.delete_doc(self)
if result['ok']
self.delete('_rev')
self.delete('_id')
@_destroyed = true
self.freeze
end
result['ok']
end
end
def destroyed?
!!@_destroyed
end
# Update the document's attributes and save. For example:
#
# doc.update_attributes :name => "Fred"