From: "ara.t.howard" Date: 2007-11-09T02:45:31+09:00 Subject: Re: alternate to case; generating a list of sub-classes On Nov 8, 2007, at 6:08 AM, Robert Klemme wrote: > > > I usually do this when I want to also recursively track subclasses: > > module Hierarchy > def inherited(cl) > superclass.instance_eval { inherited cl } > (@children ||= []) << cl > cl.extend Hierarchy > end > > attr_reader :children > end > > class Foo > extend Hierarchy > end > > class Bar < Foo > end > > class Dice < Bar > end > > p Bar.children > p Foo.children > > Cheers > > robert > > -- > use.inject do |as, often| as.you_can - without end > http://drawohara.tumblr.com/post/18708641 ;-) a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama