Module: Mongoid::Versioning::InstanceMethods

Defined in:
lib/mongoid/versioning.rb

Instance Method Summary collapse

Instance Method Details

#reviseObject

Create a new version of the Document. This will load the previous document from the database and set it as the next version before saving the current document. It then increments the version number.



17
18
19
20
21
22
23
24
# File 'lib/mongoid/versioning.rb', line 17

def revise
  last_version = self.class.first(:conditions => { :_id => id, :version => version })
  if last_version
    self.versions << last_version.clone
    self.version = version + 1
    @modifications["versions"] = [ nil, @attributes["versions"] ] if @modifications
  end
end