diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2021-10-28 14:07:11 +0200 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2021-11-23 10:50:44 +0100 |
commit | c0c2b31a35e19a47b499b57807bc0a0f9325f6d3 (patch) | |
tree | ab7ee0710597903b43a8d086a3805059693de928 /include/ruby/internal/intern | |
parent | a88b19d3d08447eeb7045621f02a844173d64203 (diff) | |
download | ruby-c0c2b31a35e19a47b499b57807bc0a0f9325f6d3.tar.gz |
Add Class#subclasses
Implements [Feature #18273]
Returns an array containing the receiver's direct subclasses without
singleton classes.
Diffstat (limited to 'include/ruby/internal/intern')
-rw-r--r-- | include/ruby/internal/intern/class.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/include/ruby/internal/intern/class.h b/include/ruby/internal/intern/class.h index 835e85c26d..2181ab93c7 100644 --- a/include/ruby/internal/intern/class.h +++ b/include/ruby/internal/intern/class.h @@ -158,7 +158,7 @@ VALUE rb_mod_included_modules(VALUE mod); VALUE rb_mod_include_p(VALUE child, VALUE parent); /** - * Queries the module's ancestors. This routine gathers classes and modules + * Queries the module's ancestors. This routine gathers classes and modules * that the passed module either inherits, includes, or prepends, then * recursively applies that routine again and again to the collected entries * until the list doesn't grow up. @@ -188,6 +188,19 @@ VALUE rb_mod_ancestors(VALUE mod); VALUE rb_class_descendants(VALUE klass); /** + * Queries the class's direct descendants. This routine gathers classes that are + * direct subclasses of the given class, + * returning an array of classes that have the given class as a superclass. + * The returned array does not include singleton classes. + * + * @param[in] klass A class. + * @return An array of classes where `klass` is the `superclass`. + * + * @internal + */ +VALUE rb_class_subclasses(VALUE klass); + +/** * Generates an array of symbols, which are the list of method names defined in * the passed class. * |