Ruby Bit For The Weekend

I was looking over the code behind the New Relic RPM plugin for Rails, and noticed a small bit of code in the following style:

@obj = SomeClass.new
# Do stuff
def @obj.a_new_method
  # add functionality
  # to obj, specifically
end

Without entering into the mostly futile discussion regarding the numerous goods / evils of this sort of monkey patching, it was a cool piece of Ruby functionality I hadn’t yet seen.

One Response to “Ruby Bit For The Weekend”

  1. Thanks for this. Just subscribed.

Leave a Reply