Project

General

Profile

Actions

Feature #18273

closed

Class#subclasses

Added by byroot (Jean Boussier) about 3 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:105826]

Description

Ref: https://github.com/rails/rails/pull/43481

Something we forgot to mention in [Feature #14394], is either a parameter or another method to only get direct descendants.

Active Support has been offering Class.subclasses as:

  def subclasses
    descendants.select { |descendant| descendant.superclass == self }
  end

It seems a bit silly to grab all descendants and then restrict the list when Class#descendants had to do some recursion to get them all in the first place.

Proposal

We could either implement Class#subclasses directly, or accept a parameter in Class#descendants, e.g. descendants(immediate = false).

cc @Eregon (Benoit Daloze)


Related issues 1 (1 open0 closed)

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0