Daniel Schierbeck wrote:
>   class Class
>     def inherited(subclass)
>       subclasses.push(subclass)
>     end
> 
>     def subclasses
>       @subclasses ||= []
>     end
>   end

Now that I think about it, this may be better:

   class Class
     def inherited(subclass)
       (@subclasses ||= []).push(subclass)
     end

     def subclasses
       (@subclasses ||= []).dup
     end
   end

That way you can somewhat avoid the problems given by

   A.subclasses.push(UnrelatedClass)


Cheers,
Daniel