Low commit activity in last 3 years
A long-lived project that still receives updates
Compatibility helpers for Mongoid.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
< 12
>= 0
~> 1.36.0

Runtime

 Project Readme

Mongoid::Compatibility

Gem Version Build Status Code Climate

Tested against:

  • MRI: 2.6.x, 2.7.x, 3.0.x, 3.1.x
  • Compatibility helpers for Mongoid versions 2, 3, 4, 5, 6, 7, 8, and 9.

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?
  
Mongoid::Compatibility::Version.mongoid8?
  # => is this Mongoid 8.x?

Instead of checking specifically for a specific version, use newer and older helpers. For example:

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

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-2022

MIT License