From: MaggotChild Date: 2009-09-18T04:45:08+09:00 Subject: Re: Monkey Patching 2 Methods, Overrides One Method, Not The Other On Sep 17, 5:02 am, "David A. Black" wrote: > Hi -- > > On Thu, 17 Sep 2009, MaggotChild wrote: > > I'm monkey patching 2 methods of an existing module: some_method() and > > another_method() > > > Calling some_method() on an instance of class that includes the > > original module works fine (calls the monkey patched version), but > > when I call another_method() the original (not the monkey patched) > > method is called. > > > There is a lot of code, and I've tried to recreate the series of > > includes with the below example, yet the example works! > > > Given this, I hope that someone could still provide me with some > > insight as to why this would happen > > I'm never quite sure what people mean by "monkey patching" > -- it always sounds like deliberately doing something badly, so that having > it not work shouldn't be a surprise :-) It sure sounds like you understand what I mean, and I agree, yet the problematic modules (mine and the one I'm attempting to override) are filled with this sort of behavior and a full rewrite is not feasible at this time. It's unfortunate that the Ruby community has adopted such an abhorrent practice to the extent it has. Furthermore, what sort of examples are we setting for the children who take up Ruby as their first language. I hope that the The Well-Grounded Rubyist isn't advocating this sort of OO flummory :^) > Can you look at the difference between your real code and your > example, and try to spot what's not working? I'd like to think that it has something to do with the way the modules are required. In the real code there are far more `requires` and even a `load`. I go back to my generalization of this problem: How can one module revert back to its original implementation on one method and not the other, when both the original and overridden methods are contained in 1 file respectively? Thanks