From: "Darryl L. Pierce" Date: 2011-09-17T05:50:36+09:00 Subject: Re: Can monkey patching be discovered when you require a library? On Tue, Sep 13, 2011 at 11:52:50AM +0900, Nick Klauer wrote: > Is it possible to know whether a method, class, or instance was overridden > by another when you require 'said_gem' in (i.e. monkeypatched)? I'm > thinking something that would let gem users know if a gem is going to > override core methods or attrs? The question is: _how_ would you find out if such were the case? Can you look at the eigenclass where the method definition is located and, from there, determine whether it's on the original class or if it's on some other class's definition? For example, I define a class named Foo: class Foo def bar; do_something; end end and then I do some monkey patching to it elsewhere: def Foo.bar; do_something_else; end How would you determine that the new definition of bar is different from the original? Or, _can_ you determine that it's fundamentally different now? -- Darryl L. Pierce http://mcpierce.multiply.com/ "What do you care what people think, Mr. Feynman?"