From: Robert Klemme Date: 2005-10-24T23:02:02+09:00 Subject: Re: How to find all the subclasses of a class? Pit Capitain wrote: > Robert Klemme schrieb: >> 1. Find them when you need them via ObjectSpace: >> >> ObjectSpace.each_object(Module) {|m| subclasses << m if >> m.ancestors.include? cl} > > If you want to find subclasses of a *class* instead of a module, you > can pass the singleton class of the base class: > > require "enumerator" > > def get_subclasses(klass) > ObjectSpace.enum_for(:each_object, class << klass; self; > end).to_a end Cool! Didn't know this. Learn something new every day... Thanks! Kind regards robert