Make core extensions cleaner with refinements #709
Merged
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.
This gem monkey-patches Object class and String class with the following four methods for the gem internal use,
Object#bullet_key
Object#bullet_primary_key_value
Object#bullet_join_potential_composite_primary_key
String#bullet_class_name
and these methods are globally polluting every Object in the whole Ruby process.
This kind of monkey-patching is a dangerous approach and should be avoided in a gem that is usually bundled only in development/test, since it may become a cause of weird bugs that happen only on production env.
So, here's a patch that encapsulates these monkey-patches inside this gem by rewriting the core-exts to use refinements.
Note that this can be an incompatible change for those who use these methods from their application code. I can hardly imagine such a use case, but in such case, they may have to add
using
calls to their application.