From 46f6a2e3889bae420589f429b09722a37dbdf18d Mon Sep 17 00:00:00 2001 From: Rolf Timmermans Date: Sat, 12 Mar 2011 23:49:25 +0800 Subject: It should be possible to use ActiveSupport::DescendantTracker without getting ActiveSupport::Dependencies for free. --- 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