35
I've noticed that there are two common ways to monkey patch a class in ruby:
Define the new members on the class like so:
class Array
def new_method
#do stuff
end
end
And calling class_eval on the class object:
Array.class_eval do
def new_method
#do stuff
end
end
I'm wondering if there is any difference between the two and whether there are advantages to using one approach over the other?