This module provides an internal implementation to track descendants which is faster than iterating through ObjectSpace.
Methods
Class Public methods
Source: show
# File activesupport/lib/active_support/descendants_tracker.rb, line 18 def self.clear if defined? ActiveSupport::Dependencies @@direct_descendants.each do |klass, descendants| if ActiveSupport::Dependencies.autoloaded?(klass) @@direct_descendants.delete(klass) else descendants.reject! { |v| ActiveSupport::Dependencies.autoloaded?(v) } end end else @@direct_descendants.clear end end
Source: show
# File activesupport/lib/active_support/descendants_tracker.rb, line 11 def self.descendants(klass) @@direct_descendants[klass].inject([]) do |descendants, _klass| descendants << _klass descendants.concat _klass.descendants end end
Source: show
# File activesupport/lib/active_support/descendants_tracker.rb, line 7 def self.direct_descendants(klass) @@direct_descendants[klass] end
Instance Public methods
Source: show
# File activesupport/lib/active_support/descendants_tracker.rb, line 41 def descendants DescendantsTracker.descendants(self) end
Source: show
# File activesupport/lib/active_support/descendants_tracker.rb, line 37 def direct_descendants DescendantsTracker.direct_descendants(self) end
Source: show
# File activesupport/lib/active_support/descendants_tracker.rb, line 32 def inherited(base) self.direct_descendants << base super end