Note that my question is different from this question because I'm asking for all descendants (including descendants of descendants) of a class.
Moreover, I would prefer to use something like
class Animal
def self.inherited(subclass)
@descendants = []
@descendants << subclass
end
def self.descendants
puts @descendants
end
end
because it's way faster than getting all classes and filtering for descendants.