From 717ab0bb2ee63dfe76076e0c9f91fbac3a0de4fd Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 26 Oct 2021 10:35:21 -0900 Subject: Add Class#descendants Doesn't include receiver or singleton classes. Implements [Feature #14394] Co-authored-by: fatkodima Co-authored-by: Benoit Daloze --- include/ruby/internal/intern/class.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/ruby/internal/intern/class.h b/include/ruby/internal/intern/class.h index 60baf98472..835e85c26d 100644 --- a/include/ruby/internal/intern/class.h +++ b/include/ruby/internal/intern/class.h @@ -174,6 +174,19 @@ VALUE rb_mod_include_p(VALUE child, VALUE parent); */ VALUE rb_mod_ancestors(VALUE mod); +/** + * Queries the class's descendants. This routine gathers classes that are + * subclasses of the given class (or subclasses of those subclasses, etc.), + * returning an array of classes that have the given class as an ancestor. + * The returned array does not include the given class or singleton classes. + * + * @param[in] klass A class. + * @return An array of classes where `klass` is an ancestor. + * + * @internal + */ +VALUE rb_class_descendants(VALUE klass); + /** * Generates an array of symbols, which are the list of method names defined in * the passed class. -- cgit v1.2.3