1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

It should be possible to use ActiveSupport::DescendantTracker without getting ActiveSupport::Dependencies for free.

This commit is contained in:
Rolf Timmermans 2011-03-12 23:49:25 +08:00 committed by José Valim
parent 58de03f077
commit 46f6a2e388

View file

@ -1,5 +1,3 @@
require 'active_support/dependencies'
module ActiveSupport module ActiveSupport
# This module provides an internal implementation to track descendants # This module provides an internal implementation to track descendants
# which is faster than iterating through ObjectSpace. # which is faster than iterating through ObjectSpace.
@ -18,6 +16,7 @@ module ActiveSupport
end end
def self.clear def self.clear
if defined? ActiveSupport::Dependencies
@@direct_descendants.each do |klass, descendants| @@direct_descendants.each do |klass, descendants|
if ActiveSupport::Dependencies.autoloaded?(klass) if ActiveSupport::Dependencies.autoloaded?(klass)
@@direct_descendants.delete(klass) @@direct_descendants.delete(klass)
@ -25,6 +24,9 @@ module ActiveSupport
descendants.reject! { |v| ActiveSupport::Dependencies.autoloaded?(v) } descendants.reject! { |v| ActiveSupport::Dependencies.autoloaded?(v) }
end end
end end
else
@@direct_descendants.clear
end
end end
def inherited(base) def inherited(base)