From: Martin Hart Date: 2002-12-12T09:03:55+09:00 Subject: How to detect Module Inclusion for Class Instances (like Module#extend_object)? Hi all. Is there a way to tell that a module is being included by a class? Specifically I want to detect this for instances of the class in question - sort of like using #extend_object. For example, module Mod def Mod.extend_object(object) object.someInstanceFunction super end end Now "someInstanceFunction" gets called if I do something like... class Blah def someInstanceFunction ... end end object = Blah.new.extend(Mod) ...But, If I do this... class Blah include Mod def someInstanceFunction ... end end object = Blah.new ... extend_object doesn't get called (unsurprisingly I guess) - so nor does "someInstanceFunction" - which is my problem. Currently using ruby 1.6.6 (2002-01-21) [i686-linux] Is there a way to call my instance function when the object is instantiated regardless of whether the module was included by #extend or by using include? Cheers, Martin -- Martin Hart Tel: +44 (0) 1582 618468 Arnclan Fax: +44 (0) 1582 619596 Union Street, E-mail: martin@zsdfherg.com Dunstable, Beds LU6 1EX