Permalink
Browse files

Revert "Revert "It should be possible to use ActiveSupport::Descendan…

…tTracker without getting ActiveSupport::Dependencies for free.""

This reverts commit 9f5b1e1.

Tests have been refactored so they pass in isolation.
  • Loading branch information...
1 parent 76e4e2f commit d89a7967b5af5c87bbfc268af72287b82541d384 Rolf Timmermans committed Mar 13, 2011
Showing with 9 additions and 7 deletions.
  1. +9 −7 activesupport/lib/active_support/descendants_tracker.rb
View
16 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 @@ def self.descendants(klass)
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

0 comments on commit d89a796

Please sign in to comment.