Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MONGOID-5653 - Move Hash#__nested__ monkey patch method to new module Mongoid::Attributes::Embedded.traverse #5692

Merged
merged 5 commits into from
Aug 28, 2023

Conversation

johnnyshields
Copy link
Contributor

@johnnyshields johnnyshields commented Aug 27, 2023

Hash#__nested__ is an unnecessary monkey patch which is only used in one place. Let's remove it.

Moreover, it's logic duplicates the code in Mongoid::Reloadable#extract_embedded_attributes

This PR consolidates and refactors the logic, and fixes a number of edge-cases and adds lots of specs.

This PR also removes the maybe_integer Util method, because it doesn't do the correct thing. For example, a Hash may have a string literal key "100", but maybe_integer will always convert this to numeric 100. (This case was actually covered in the pre-existing __nested__ specs.)

@johnnyshields johnnyshields changed the title Move Hash#__nested__ monkey patch method to new module Mongoid::Attributes::Embedded.traverse MONGOID-5653 - Move Hash#__nested__ monkey patch method to new module Mongoid::Attributes::Embedded.traverse Aug 27, 2023
@johnnyshields
Copy link
Contributor Author

The failing spec for ruby-2.7 is not related to this PR.

Copy link
Contributor

@jamis jamis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thank you @johnnyshields

@jamis jamis merged commit f674f2e into mongodb:master Aug 28, 2023
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants