From d89a7967b5af5c87bbfc268af72287b82541d384 Mon Sep 17 00:00:00 2001 From: Rolf Timmermans Date: Sun, 13 Mar 2011 17:08:33 +0100 Subject: Revert "Revert "It should be possible to use ActiveSupport::DescendantTracker without getting ActiveSupport::Dependencies for free."" This reverts commit 9f5b1e1ed08df9dbedded0a6b7798d919d43b9a6. Tests have been refactored so they pass in isolation. --- activesupport/lib/active_support/descendants_tracker.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'activesupport/lib/active_support/descendants_tracker.rb') diff --git a/activesupport/lib/active_support/descendants_tracker.rb b/activesupport/lib/active_support/descendants_tracker.rb index 4d1cfacc95..e2a8b4d4e3 100644 --- a/activesupport/lib/active_support/descendants_tracker.rb +++ b/activesupport/lib/active_support/descendants_tracker.rb @@ -1,5 +1,3 @@ -require 'active_support/dependencies' - module ActiveSupport # This module provides an internal implementation to track descendants # which is faster than iterating through ObjectSpace. @@ -18,12 +16,16 @@ module ActiveSupport end def self.clear - @@direct_descendants.each do |klass, descendants| - if ActiveSupport::Dependencies.autoloaded?(klass) - @@direct_descendants.delete(klass) - else - descendants.reject! { |v| ActiveSupport::Dependencies.autoloaded?(v) } + 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 -- cgit v1.2.3