# module ActiveSupport::DescendantsTracker

This module provides an internal implementation to track descendants which is faster than iterating through ObjectSpace.

### Public Class Methods

clear() click to toggle source

    # File 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

descendants(klass) click to toggle source

    # File 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

direct_descendants(klass) click to toggle source

    # File lib/active_support/descendants_tracker.rb, line 7
    def self.direct_descendants(klass)
      @@direct_descendants[klass]
    end

### Public Instance Methods

descendants() click to toggle source

    # File lib/active_support/descendants_tracker.rb, line 41
    def descendants
      DescendantsTracker.descendants(self)
    end

direct_descendants() click to toggle source

    # File lib/active_support/descendants_tracker.rb, line 37
    def direct_descendants
      DescendantsTracker.direct_descendants(self)
    end

inherited(base) click to toggle source

    # File lib/active_support/descendants_tracker.rb, line 32
    def inherited(base)
      self.direct_descendants << base
      super
    end