aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/descendants_tracker.rb
diff options
context:
space:
mode:
authorRolf Timmermans <r.timmermans@voormedia.com>2011-03-12 23:49:25 +0800
committerJosé Valim <jose.valim@gmail.com>2011-03-13 01:33:10 +0800
commit46f6a2e3889bae420589f429b09722a37dbdf18d (patch)
treebaa834df1b4a442da13cf67f94982d32f52672ff /activesupport/lib/active_support/descendants_tracker.rb
parent58de03f077b0da1cb923f28835b00cd092de3c08 (diff)
downloadrails-46f6a2e3889bae420589f429b09722a37dbdf18d.tar.gz
rails-46f6a2e3889bae420589f429b09722a37dbdf18d.tar.bz2
rails-46f6a2e3889bae420589f429b09722a37dbdf18d.zip
It should be possible to use ActiveSupport::DescendantTracker without getting ActiveSupport::Dependencies for free.
Diffstat (limited to 'activesupport/lib/active_support/descendants_tracker.rb')
-rw-r--r--activesupport/lib/active_support/descendants_tracker.rb16
1 files changed, 9 insertions, 7 deletions
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