diff --git a/lib/couchrest/model/persistence.rb b/lib/couchrest/model/persistence.rb index a9e0a756..63ced310 100644 --- a/lib/couchrest/model/persistence.rb +++ b/lib/couchrest/model/persistence.rb @@ -6,12 +6,12 @@ module Persistence # 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 # be returned. - def create(options = {}) + def create(options = {}, bulk = false) return false unless perform_validations(options) _run_create_callbacks do _run_save_callbacks do set_unique_id if new? && self.respond_to?(:set_unique_id) - result = database.save_doc(self) + result = database.save_doc(self, bulk = bulk) ret = (result["ok"] == true) ? self : false @changed_attributes.clear if ret && @changed_attributes ret @@ -27,14 +27,14 @@ def create!(options = {}) # Trigger the callbacks (before, after, around) # only if the document isn't new - def update(options = {}) + def update(options = {}, bulk = false) raise "Cannot save a destroyed document!" if destroyed? raise "Calling #{self.class.name}#update on document that has not been created!" if new? return false unless perform_validations(options) return true if !self.disable_dirty && !self.changed? _run_update_callbacks do _run_save_callbacks do - result = database.save_doc(self) + result = database.save_doc(self, bulk = bulk) ret = result["ok"] == true @changed_attributes.clear if ret && @changed_attributes ret @@ -43,8 +43,8 @@ def update(options = {}) end # Trigger the callbacks (before, after, around) and save the document - def save(options = {}) - self.new? ? create(options) : update(options) + def save(options = {}, bulk = false) + self.new? ? create(options, bulk) : update(options, bulk) end # Saves the document to the db using save. Raises an exception