| Start |
|---|
| Monkey patching with limited scope Monkey patching's main issue is that it pollutes the global scope. Your code working is at the mercy of all the modules you use not stepping on each others toes. The Ruby solution to this is refinements, which are basically monkey patches in a limited scope. |
| Dual-purpose modules (refinements or global patches) It's a good practice to scope patches using Refinements, but sometimes it's nice to load it globally (for example in development, or testing). Say for example you want to start a console, require your library, and then have the patched methods available in the global scope. You couldn't do this with refinements because |
| Dynamic refinements Refinements have special limitations.
An example showing these concepts: Since Calling the proc creates the patched class RemarksRefinements are scope lexically, meaning they're in effect from the time they're activated (with the |
Read Article
https://develop.horje.com/learn/1434/reference