diff options
author | Xavier Noria <fxn@hashref.com> | 2019-04-09 11:06:44 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2019-04-09 11:06:44 +0200 |
commit | 9b5401fcc9624be9bd60331d59169267ae2f7bac (patch) | |
tree | 1e28b8596386b03ecfc526ec9e5eb81d3678fc2e /activesupport/lib | |
parent | 496e8ee9370e9f165fd1f5d2620296299a6a8649 (diff) | |
download | rails-9b5401fcc9624be9bd60331d59169267ae2f7bac.tar.gz rails-9b5401fcc9624be9bd60331d59169267ae2f7bac.tar.bz2 rails-9b5401fcc9624be9bd60331d59169267ae2f7bac.zip |
depend on Zeitwerk 2.1.0
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/dependencies/zeitwerk_integration.rb | 13 | ||||
-rw-r--r-- | activesupport/lib/active_support/descendants_tracker.rb | 11 |
2 files changed, 11 insertions, 13 deletions
diff --git a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb index faf9edef27..b0f7a3f9cc 100644 --- a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb +++ b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb @@ -21,17 +21,8 @@ module ActiveSupport ActiveSupport::Inflector.safe_constantize(cpath) end - def autoloaded_constants - cpaths = [] - Rails.autoloaders.each do |autoloader| - cpaths.concat(autoloader.loaded_cpaths.to_a) - end - cpaths - end - - def autoloaded?(object) - cpath = object.is_a?(Module) ? object.name : object.to_s - Rails.autoloaders.any? { |autoloader| autoloader.loaded?(cpath) } + def to_unload?(cpath) + Rails.autoloaders.main.to_unload?(cpath) end def verbose=(verbose) diff --git a/activesupport/lib/active_support/descendants_tracker.rb b/activesupport/lib/active_support/descendants_tracker.rb index 2dca990712..fe0c6991aa 100644 --- a/activesupport/lib/active_support/descendants_tracker.rb +++ b/activesupport/lib/active_support/descendants_tracker.rb @@ -22,11 +22,18 @@ 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 ActiveSupport::Dependencies.autoloaded?(klass) + if to_unload[klass] @@direct_descendants.delete(klass) else - descendants.reject! { |v| ActiveSupport::Dependencies.autoloaded?(v) } + descendants.reject! { |v| to_unload[v] } end end else |