-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
Mongoid defines === for Mongoid::Document class and its instances (two separate implementations). The existing implementation calls this operator an "equality" one. However, the post at https://dev.to/baweaver/understanding-ruby-triple-equals-2p9c suggests the === operatior is really a membership operator rather than an equality operator (which would explain why, for example, === is false for some class comparisons to itself, e.g. String === String is false but Object === Object is true).
Given the changes already made in https://jira.mongodb.org/browse/MONGOID-5126, which applied to class-level === implementation in Mongoid, I think we should review the instance-level implementation as well and ensure both are consistent with "=== is a membership operator" idea.
Make instance level === delegate to super when legacy behavior is off
Review all specs in spec/mongoid/equality_spec.rb that use ===, ensure both values of the flag are tested
Update release note for === change to show examples of different legacy behavior - already done
Move === implementation from mongoid/document.rb to mongoid/equality.rb
- depends on
-
MONGOID-5247 Change feature flag names to be reflective of user-visible behavior
- Closed
- related to
-
MONGOID-5258 Review enumerable === implementation
- Closed
-
MONGOID-5126 Bring Mongoid::Document's === implementation in alignment with Ruby behavior
- Closed