This question is similar / related to another question about Finding all descendants of a class in Ruby . A wonderful question full of information I was looking for - except when I go down to the rails console:
irb(main):001:0> ActiveSupport::DescendantsTracker.descendants(Object) =>[] irb(main):002:0> ObjectSpace.each_object(Class).select { |klass| klass < Object } => [IRB::Notifier::AbstractNotifier, IRB::Notifier::ErrUnrecognizedLevel, ...]
So why doesn't ActiveSupport :: DescendantsTracker return the children of the object? What are the differences in implementation? The documentation for DescendantsTracker assumes that:
This module provides an internal implementation for tracking children, which is faster than repetition through ObjectSpace.
Faster? Well, you need to return something faster (what?), But it should return the descendants of the supplied class.
source share