aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRolf Timmermans <r.timmermans@voormedia.com>2011-03-13 17:08:33 +0100
committerRolf Timmermans <r.timmermans@voormedia.com>2011-03-13 17:08:33 +0100
commitd89a7967b5af5c87bbfc268af72287b82541d384 (patch)
tree1547760692d70f51406a8afcc73e95fa0d0f741c
parent76e4e2fa468593c42623472055d329dfeb577c49 (diff)
downloadrails-d89a7967b5af5c87bbfc268af72287b82541d384.tar.gz
rails-d89a7967b5af5c87bbfc268af72287b82541d384.tar.bz2
rails-d89a7967b5af5c87bbfc268af72287b82541d384.zip
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.
-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