Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 2.84 KB

README.md

File metadata and controls

80 lines (58 loc) · 2.84 KB

mongoid-versioning Build Status

Important: This gem is an extraction of Mongoid::Versioning from the official mongoid gem. Since Mongoid::Versioning was removed in the 4.0.0 release of Mongoid, this gem re-enables the functionality of versioned documents.

Please submit only bug and security fixes. Neither I will accept new features nor changes to existing APIs. Please consider forking the project if you want new features to appear! :)


Mongoid supports simple versioning through inclusion of the Mongoid::Versioning module. Including this module will create a versions embedded relation on the document that it will append to on each save. It will also update the version number on the document, which is an integer.

Installation

In your Gemfile:

gem 'mongoid-versioning'

Usage

class Person
  include Mongoid::Document
  include Mongoid::Versioning
end

You can also set a max_versions setting, and Mongoid will only keep the max most recent versions.

class Person
  include Mongoid::Document
  include Mongoid::Versioning

  # keep at most 5 versions of a record
  max_versions 5
end

You may skip versioning at any point in time by wrapping the persistence call in a versionless block.

person.versionless do |doc|
  doc.update_attributes(name: "Theodore")
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

(The MIT license)

Copyright (c) 2009-2013 Durran Jordan, 2013-2015 Mario Uher

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.