Ruby 3.1 adds subclasses method
By Abhishek Kanojia on January 21, 2022
Ruby 3.1 adds Class#subclasses
method, which returns an array of subclasses directly inheriting from the
receiver, not including singleton classes.
class Parent; end
class ChildA < Parent; end
class ChildB < Parent; end
class GrandChildA < ChildA; end
Parent.subclasses
=> [ChildA, ChildB]
ChildA.subclasses
=> [GrandChildA]
GrandChildA.subclasses
=> []
Reference #Pull Request