Compatibility helpers for the many Mongoid versions.
Ruby
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Mongoid::Compatibility

Gem Version Build Status Dependency Status Code Climate

Compatibility helpers for Mongoid versions 2, 3, 4, 5, 6 and 7.

Install

Add mongoid-compatibility to your Gemfile.

gem 'mongoid-compatibility'

You may explicitly need to require mongoid/compatibility.

Use

Mongoid::Compatibility::Version

Mongoid::Compatibility::Version.mongoid2?
  # => is this Mongoid 2.x?

Mongoid::Compatibility::Version.mongoid3?
  # => is this Mongoid 3.x?

Mongoid::Compatibility::Version.mongoid4?
  # => is this Mongoid 4.x?

Mongoid::Compatibility::Version.mongoid5?
  # => is this Mongoid 5.x?

Mongoid::Compatibility::Version.mongoid6?
  # => is this Mongoid 6.x?

Mongoid::Compatibility::Version.mongoid7?
  # => is this Mongoid 7.x?

Instead of checking for Mongoid 6 and 7, use newer and older helpers.

Mongoid::Compatibility::Version.mongoid6_or_newer?
  # => is this Mongoid 6.x or 7.x, including beta 7?

Mongoid::Compatibility::Version.mongoid5_or_older?
  # => is this Mongoid 2.x, 3.x, 4.x or 5.x?

Mongoid::Compatibility::ObjectId

Mongoid::Compatibility::ObjectId.legal?('4e4d66343b39b68407000001')
  # => is this a valid BSON ID?

Contribute

See CONTRIBUTING.

Copyright and License

Copyright Daniel Doubrovkine and Contributors, Artsy Inc., 2015-2017

MIT License