MONGOID-5673 [Monkey Patch Removal] Remove Object#do_or_do_not and Object#you_must #5713
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-5673
Object#do_or_do_not and Object#you_must are kernel monkey patches which are similar to #try. Someone got cute and added Star Wars Yoda references
#do_or_do_not, there is no #try
.For
#do_or_do_not
usages which can obviously be replaced with#try
or#send
I've done so. The remaining usages are localized to theBindable
module, so I've added a convenience method there which I've named#try_method
.For
#you_must
, I've inlined the call theif frozen?
No tests added here because the method is private and trivial.
Note about Future Refactoring
#try
(and#try_method
used here) are code smells.#try_method
should be removed entirely in in the future, but at least for now it's localized to theBindable
module (far better than a monkey patch onObject
.)Overall progress is tracked here: http://tinyurl.com/mongoid-monkey. Refer to MONGOID-5660 for context.