hi jérémy! Jérémy Zurcher [2008-08-03 22:48]: > module M2; end > class C2; include M2; end > module M2; def m; puts "hello world" end; end > C2.new.m > > >> hello world > > module M5; def m; puts "hello world" end; end > module M4; include M5; end > class C4; include M4; end > C4.new.m > > >> hello world > > module M7; def m; puts "hello world" end; end > module M6; end > class C5; include M6; end > module M6 include M7; end > C5.new.m > > >> test.rb:13: undefined method `m' for #<C5:0xb7ca02bc> (NoMethodError) > > obviously M7 is not found in the ansestors of C5, has show by the ancestors > method. as i see it, that's actually the point. when you include some module M in a class C, M and all its ancestors will be added to C's module hierarchy (where methods and constants are looked up). but there's no further connection or coupling between the two hierarchies. adding to M's hierarchy doesn't affect C's in any way. even removing M has no consequences for C at that point ;-) the only thing you could probably do is something along the lines of: module M def m; 'm'; end def self.included(base) if receivers = base.instance_variable_get(:@receivers) receivers.each { |r| r.send(:include, self) } end end end module N @receivers = [] def self.included(base); @receivers << base; end end class C; include N; end C.new.m #=> undefined method `m' for #<C:0x2b5946f01818> module N; include M; end C.new.m #=> "m" cheers jens -- Jens Wille, Dipl.-Bibl. (FH) prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre Kunsthistorisches Institut der Universität zu Köln Albertus-Magnus-Platz, D-50923 Köln Tel.: +49 (0)221 470-6668, E-Mail: jens.wille / uni-koeln.de http://www.prometheus-bildarchiv.de/