Should I let you in on a secret? ‘I monkey patch from time to time’. Uhh. Okay, it’s in the title. You clicked. So I guess you do so as well, ri

“I monkey patch from time to time.”

submited by
Style Pass
2023-02-07 13:00:27

Should I let you in on a secret? ‘I monkey patch from time to time’. Uhh. Okay, it’s in the title. You clicked. So I guess you do so as well, right? We Rubyists all do from time to time I guess.

According to Wikipedia, a “Monkey patch is a technique used to dynamically update the behavior of a piece of code at run-time.”

The awesome reflective capabilities of rails allow this. I wrote a small gem that hooks into a loading application, bookkeeps every class and its methods, and then once the application has fully loaded checks again to see if the original implementation still is the one that’s in charge.

That gem is called ‘overrides_tracker’. Should have called it something more funky like “monkey catcher”, but that’s a different topic.

So okay, now you know what you or others have patched — maybe even outside your codebase like in GEMs you use. Fine. What about the other three points on that list?

Leave a Comment