Skip to Content Skip to Search

class Class

Public instance methods

Returns an array with all classes that are < than its receiver.

class C; end
C.descendants # => []

class B < C; end
C.descendants # => [B]

class A < B; end
C.descendants # => [B, A]

class D < C; end
C.descendants # => [B, A, D]
Source code GitHub
# File activesupport/lib/active_support/core_ext/class/subclasses.rb, line 19
def descendants
  subclasses.concat(subclasses.flat_map(&:descendants))
end

Definition files