Sha256: b17a9a1a5c6fa018191166ba7854ddab6ca53c6c37fc0d8f01ecfd91550f3e5c
Contents?: true
Size: 519 Bytes
Versions: 4
Compression:
Stored size: 519 Bytes
Contents
class Class # List all descedents of this class. # # class X ; end # class A < X; end # class B < X; end # X.descendents #=> [A,B] # # NOTE: This is a intesive operation. Do not # expect it to be super fast. def descendents subclass = [] ObjectSpace.each_object( Class ) do |c| if c.ancestors.include?( self ) and self != c subclass << c end end return subclass end # Obvious alias for descendents. alias_method :subclasses, :descendents end
Version data entries
4 entries across 4 versions & 1 rubygems