Project

General

Profile

Actions

Feature #9779

open

Add Module#descendents

Added by shugo (Shugo Maeda) over 10 years ago. Updated almost 7 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:62193]

Description

Now classes have links to their subclasses, so how about to add Module#descendents?

class X
end

class Y < X
end

class Z < Y
end

p X.descendents    #=> [X, Y, Z]

module A
end

module B
  include A
end

module C
  include A
end

p A.descendents    #=> [A, C, B]

One of my own use cases is to implement AspectJ like pointcut which matches all subclasses of the given class.

Considerations:

  • Should the return value of Module#descendents include self?
  • Should the return value of Module#descendents include singleton classes?

I attach a patch, where the return value includes both self and singleton classes.


Files

0001-Add-Module-descendents.patch (3.75 KB) 0001-Add-Module-descendents.patch shugo (Shugo Maeda), 04/28/2014 07:00 AM

Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #14394: Class.descendantsAssignedko1 (Koichi Sasada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0