MONGOID-5677 [Monkey Patch Removal] Remove Hash#to_criteria and Criteria#to_criteria. Add Criteria.from_hash #5717
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes MONGOID-5677
Hash#to_criteria
is a kernel Monkey patch that converts a Hash to a Criteria by currying its key-values to an initialized Criteria class. It looks like it was done in order to support passing in a hash as an arg toCriteria.merge!
, there's not a major use for it otherwise (Criteria
also doesn't define#to_h
)This PR does the following:
Hash#to_criteria
Criteria#to_criteria
, which just returns self.Criteria.from_hash
and add specs for it (there were no specs forHash#to_criteria
) It's debatable whether we should even add this, but someone might be usingHash#to_criteria
so oh well...Criteria.merge!
in the case that a Hash is given as an argument.In addition to this PR, I will raise a deprecation PR for Mongoid 8.2 that provides a stable upgrade path.
Overall progress is tracked here: http://tinyurl.com/mongoid-monkey. Refer to MONGOID-5660 for context.