How not to cut your source with sharp knife as Monkey Patch in Ruby
One of the most powerful Ruby features is the ability to re-open any class and change it’s methods.
Actually, you can reopen any class and change how it works. This includes the default Ruby classes like String, Array or Hash. It sounds extremely challenging. Being able to change the expected outcome of a method can cause all sorts of weird behavior and difficult to track down bugs. Monkey Patch to help. In Ruby, the term monkey patch(MP) mean any dynamic modification to a class and is often used as a synonym for dynamically modifying any class (add new or overwrite existing methods) at runtime.
As you see, Ruby is like a sharp knife, it can be extremely effective, but it’s usually your own fault if you cut yourself. Let me explain https://blog.active-bridge.com/how-not-to-cut-your-source-with-sharp-knife-as-monkey-patch-in-ruby#post
Post a comment