2008/6/11 George Malamidis <george / nutrun.com>:
> Does anyone know if there's a hook, or other means for capturing the methods
> added to an instance when the instance extends a module? (...)

None that I know. There's the Module#extended hook:

  module Bar
   def whatever;end
   def self.extended(obj)
     p obj, self, instance_methods
   end
  end

  foo = Foo.new
  foo.extend(Bar)

which give the following output:

  #<Foo:0x2aea054>
  Bar
  ["whatever"]

But I suppose you want it the other way round and define this behavior
on the class Foo or on one of its instances. If so, you could simply
override the Object#extend method:

  class Foo
    def extend(mod)
      super
      p self, mod, mod.instance_methods
    end
  end

which gives the same output as above.

Regards,
Pit