From: "F. Senault" Date: 2007-07-25T18:00:06+09:00 Subject: Re: Help: Get list of modules which are included in the class Le 25 juillet � 08:44, FireAphis@gmail.com a �crit : > I think that Chirag wanted to get only M2 and as you can see we get M1 > as well. I personally think that there is no way to solve this. As far > as I know Ruby holds its ancestors internally in a plain list and > doesn't remember the hierarchy. Can someone tell more on this matter? You can always build the list yourself : #! /usr/local/bin/ruby class Module attr_accessor :children def included(c) @children ||= [] @children << c end end module M1 end module M2 include M1 end class C1 include M2 end class C2 < C1 include M2 end C1.ancestors.each { |x| puts "#{x} : #{x.children.inspect}" } p C1.ancestors.select { |x| x.instance_of?(Module) && x.children && x.children.include?(C1) } Gives : C1 : nil M2 : [C1, C2] M1 : [M2] Object : nil Kernel : nil [M2] (Not very much tested, but the idea is there, I think.) Fred -- I can imagine the moment Breaking out through the silence All the things that we both might say And the heart it will not be denied 'Til we're both on the same damn side All the barriers blown away (Peter Gabriel, Come Talk to Me)