Skip to content
This repository
Browse code

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...
commit d89a7967b5af5c87bbfc268af72287b82541d384 1 parent 76e4e2f
Rolf Timmermans authored

Showing 1 changed file with 9 additions and 7 deletions. Show diff stats Hide diff stats

  1. +9 7 activesupport/lib/active_support/descendants_tracker.rb
16 activesupport/lib/active_support/descendants_tracker.rb
... ... @@ -1,5 +1,3 @@
1   -require 'active_support/dependencies'
2   -
3 1 module ActiveSupport
4 2 # This module provides an internal implementation to track descendants
5 3 # which is faster than iterating through ObjectSpace.
@@ -18,12 +16,16 @@ def self.descendants(klass)
18 16 end
19 17
20 18 def self.clear
21   - @@direct_descendants.each do |klass, descendants|
22   - if ActiveSupport::Dependencies.autoloaded?(klass)
23   - @@direct_descendants.delete(klass)
24   - else
25   - descendants.reject! { |v| ActiveSupport::Dependencies.autoloaded?(v) }
  19 + if defined? ActiveSupport::Dependencies
  20 + @@direct_descendants.each do |klass, descendants|
  21 + if ActiveSupport::Dependencies.autoloaded?(klass)
  22 + @@direct_descendants.delete(klass)
  23 + else
  24 + descendants.reject! { |v| ActiveSupport::Dependencies.autoloaded?(v) }
  25 + end
26 26 end
  27 + else
  28 + @@direct_descendants.clear
27 29 end
28 30 end
29 31

0 comments on commit d89a796

Please sign in to comment.
Something went wrong with that request. Please try again.