Navigation

Mongoid 7.4

This page describes significant changes and improvements in Mongoid 7.4. The complete list of releases is available on GitHub and in JIRA; please consult GitHub releases for detailed release notes and JIRA for the complete list of issues fixed in each release, including bug fixes.

Ruby Version Support

As of version 7.4, Mongoid supports Ruby 2.5+. Support for Ruby 2.4 and earlier has been dropped.

=== Operator Matches Ruby Semantics

Breaking change: In Mongoid 7.4, the === operator works the same way as it does in Ruby, and is equivalent to calling is_a? on the right hand side with the left hand side as the argument:

ModelClass === instance

# equivalent to:
instance.is_a?(ModelClass)

Previously, === returned true for some cases when the equivalent Ruby === implementation returned false.

Mongoid 7.4 behavior:

class Band
  include Mongoid::Document
end

class CoverBand < Band
end

band = Band.new
cover_band = CoverBand.new

band === Band
# => false

cover_band === Band
# => false

Band === Band
# => false

CoverBand === Band
# => false

Mongoid 7.3 behavior:

band === Band
# => true

cover_band === Band
# => true

Band === Band
# => true

CoverBand === Band
# => true

The standard invocation of ===, that is having the class on the left and the instance on the right, works the same in Mongoid 7.4 as it did previously and matches the core Ruby behavior:

Band === band
# => true

Band === cover_band
# => true

BSON::ObjectId#as_json Implementation Removed

Mongoid in versions up to 7.3 used to provide a BSON::ObjectId#as_json implementation that was identical to the one provided by bson-ruby. Mongoid 7.4 removes its copy of this implementation.

This change has no immediate impact on applications - BSON::ObjectId#as_json behaves the same in Mongoid 7.4 as it did in Mongoid 7.3. However, if this implementation is changed in a future version of bson-ruby which is under consideration, Mongoid 7.4 and later will inherit the new implementation provided by bson-ruby while Mongoid 7.3 and earlier will continue with the implementation returning a hash of {"$oid" => "..."}.

←   Release Notes Mongoid 7.3  →