Ruby Language Monkey Patching in Ruby

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

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.

Remarks

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?