Ruby Language Monkey Patching in Ruby


Monkey Patching is a way of modifying and extending classes in Ruby. Basically, you can modify already defined classes in Ruby, adding new methods and even modifying previously defined methods.


Monkey patching is often used to change the behavior of existing ruby code, from gems for instance.

For instance, see this gist.

It can also be used to extend existing ruby classes like Rails does with ActiveSupport, here is an example of that.