Module: Utilities::Subclasses
- Defined in:
- lib/utilities/utilities.rb
Instance Method Summary collapse
-
#subclasses(direct = false) ⇒ Object
Find every subclass of an object.
Instance Method Details
#subclasses(direct = false) ⇒ Object
Find every subclass of an object.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/utilities/utilities.rb', line 11 def subclasses(direct = false) classes = [] if direct ObjectSpace.each_object(Class) do |c| classes << c if c.superclass == self end else ObjectSpace.each_object(Class) do |c| classes << c if c.ancestors.include?(self) and (c != self) end end classes end |