Skip to content

Commit e666ea7

Browse files
mdehoogp
andauthored
MONGOID-5126 Bring Mongoid::Document's === implementation in alignment with Ruby behavior (#5013)
* Remove Mongoid::Document === override * Re-add === with correct implementation * repair specs and document the change * repair the docs Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 8d72d89 commit e666ea7

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

source/release-notes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Release Notes
99
.. toctree::
1010
:titlesonly:
1111

12+
release-notes/mongoid-7.4
1213
release-notes/mongoid-7.3
1314
release-notes/mongoid-7.2
1415
release-notes/mongoid-7.1

source/release-notes/mongoid-7.4.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
***********
2+
Mongoid 7.4
3+
***********
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
This page describes significant changes and improvements in Mongoid 7.4.
14+
The complete list of releases is available `on GitHub
15+
<https://github.com/mongodb/mongoid/releases>`_ and `in JIRA
16+
<https://jira.mongodb.org/projects/MONGOID?selectedItem=com.atlassian.jira.jira-projects-plugin:release-page>`_;
17+
please consult GitHub releases for detailed release notes and JIRA for
18+
the complete list of issues fixed in each release, including bug fixes.
19+
20+
21+
``===`` Operator Matches Ruby Semantics
22+
---------------------------------------
23+
24+
**Breaking change:** In Mongoid 7.4, the ``===`` operator works the same way
25+
as it does in Ruby, and is equivalent to calling ``is_a?`` on the right hand
26+
side with the left hand side as the argument:
27+
28+
.. code-block:: ruby
29+
30+
ModelClass === instance
31+
32+
# equivalent to:
33+
instance.is_a?(ModelClass)
34+
35+
Previously, ``===`` returned ``true`` for some cases when the equivalent Ruby
36+
``===`` implementation returned false.
37+
38+
Mongoid 7.4 behavior:
39+
40+
.. code-block:: ruby
41+
42+
class Band
43+
include Mongoid::Document
44+
end
45+
46+
class CoverBand < Band
47+
end
48+
49+
band = Band.new
50+
cover_band = CoverBand.new
51+
52+
band === Band
53+
# => false
54+
55+
cover_band === Band
56+
# => false
57+
58+
Band === Band
59+
# => false
60+
61+
CoverBand === Band
62+
# => false
63+
64+
Mongoid 7.3 behavior:
65+
66+
.. code-block:: ruby
67+
68+
band === Band
69+
# => true
70+
71+
cover_band === Band
72+
# => true
73+
74+
Band === Band
75+
# => true
76+
77+
CoverBand === Band
78+
# => true
79+
80+
The standard invocation of ``===``, that is having the class on the left and
81+
the instance on the right, works the same in Mongoid 7.4 as it did previously
82+
and matches the core Ruby behavior:
83+
84+
.. code-block:: ruby
85+
86+
Band === band
87+
# => true
88+
89+
Band === cover_band
90+
# => true

0 commit comments

Comments
 (0)