From: FireAphis Date: 2007-07-25T20:04:59+09:00 Subject: Re: Help: Get list of modules which are included in the class On Jul 25, 12:42 pm, dohzya wrote: > Le mercredi 25 juillet 2007 � 18:24 +0900, Robert Dober a �crit : > > > On 7/25/07, dohzya wrote: > > > How about (C2.ancestors - [C2] - C2.superclass.ancestors) ? > > You got it, indeed it was not so chellanging after all :( > > > Cheers > > Robert > > There is a problem : > --- > module M1 ; end > module M2 ; end > class C1 ; include M1 ; end > class C2 < C1 ; include M1 ; include M2 ; end > > p (C2.ancestors - [C2] - C2.superclass.ancestors) # => [M2] > --- > I don't know if it is a severe problem... > > -- > Etienne Vallette d'Osia There is another problem. If C2 doesn't inherit another class but does include the modules and those modules by themselves include modules then your code, still, will return the whole hierarchy. Look at this: module M1; end module M2; include M1; end class C2; include M2; end p (C2.ancestors - [C2] - C2.superclass.ancestors) # => [M1, M2] That's because C2.superclass => Object :( FireAphis