Ruby Language Monkey Patching in Ruby

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


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.

Got any Ruby Language Question?