instance method
descendants
Ruby on Rails 6.0.6
Since v5.2.8.1Signature
descendants()
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
# File activesupport/lib/active_support/core_ext/class/subclasses.rb, line 21
def descendants
descendants = []
ObjectSpace.each_object(singleton_class) do |k|
next if k.singleton_class?
descendants.unshift k unless k == self
end
descendants
end
Defined in activesupport/lib/active_support/core_ext/class/subclasses.rb line 21
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Class