Class: Class
- Inherits:
-
Object
- Object
- Class
- Defined in:
- lib/tapioca/core_ext/class.rb
Overview
typed: false frozen_string_literal: true
Instance Method Summary collapse
-
#descendants ⇒ Object
Returns an array with all classes that are < than its receiver.
Instance Method Details
#descendants ⇒ Object
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]
18 19 20 21 22 |
# File 'lib/tapioca/core_ext/class.rb', line 18 def descendants ObjectSpace.each_object(singleton_class).reject do |k| k.singleton_class? || k == self end end |