diff options
Diffstat (limited to 'activesupport/lib/active_support/descendants_tracker.rb')
-rw-r--r-- | activesupport/lib/active_support/descendants_tracker.rb | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/descendants_tracker.rb b/activesupport/lib/active_support/descendants_tracker.rb index fe0c6991aa..b14842bf67 100644 --- a/activesupport/lib/active_support/descendants_tracker.rb +++ b/activesupport/lib/active_support/descendants_tracker.rb @@ -22,18 +22,11 @@ module ActiveSupport def clear if defined? ActiveSupport::Dependencies - # to_unload? is only defined in Zeitwerk mode. - to_unload = if Dependencies.respond_to?(:to_unload?) - ->(klass) { Dependencies.to_unload?(klass.name) } - else - ->(klass) { Dependencies.autoloaded?(klass) } - end - @@direct_descendants.each do |klass, descendants| - if to_unload[klass] + if Dependencies.autoloaded?(klass) @@direct_descendants.delete(klass) else - descendants.reject! { |v| to_unload[v] } + descendants.reject! { |v| Dependencies.autoloaded?(v) } end end else @@ -48,7 +41,6 @@ module ActiveSupport end private - def accumulate_descendants(klass, acc) if direct_descendants = @@direct_descendants[klass] direct_descendants.each do |direct_descendant| @@ -85,15 +77,17 @@ module ActiveSupport end def <<(klass) - cleanup! @refs << WeakRef.new(klass) end def each - @refs.each do |ref| + @refs.reject! do |ref| yield ref.__getobj__ + false rescue WeakRef::RefError + true end + self end def refs_size |