aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2019-04-23 00:36:14 +0200
committerXavier Noria <fxn@hashref.com>2019-04-23 01:18:21 +0200
commit1b2efe5a111941d57edbaf2be7f3a94eb02b5f9d (patch)
tree6829f4218faa04a0ac7b2cf571eb9e9281e67b1a /activesupport
parentcc834db1d0815744cfa173813c05d928e008e167 (diff)
downloadrails-1b2efe5a111941d57edbaf2be7f3a94eb02b5f9d.tar.gz
rails-1b2efe5a111941d57edbaf2be7f3a94eb02b5f9d.tar.bz2
rails-1b2efe5a111941d57edbaf2be7f3a94eb02b5f9d.zip
upgrades Zeitwerk to 2.1.4
This commit more or less undoes 9b5401f, restores autoloaded? not to touch the descendants tracker, and autoloaded_constants because it is documented in the guide.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/activesupport.gemspec2
-rw-r--r--activesupport/lib/active_support/dependencies/zeitwerk_integration.rb9
-rw-r--r--activesupport/lib/active_support/descendants_tracker.rb11
3 files changed, 10 insertions, 12 deletions
diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec
index dd2340cdd3..7ecbafc911 100644
--- a/activesupport/activesupport.gemspec
+++ b/activesupport/activesupport.gemspec
@@ -34,5 +34,5 @@ Gem::Specification.new do |s|
s.add_dependency "tzinfo", "~> 1.1"
s.add_dependency "minitest", "~> 5.1"
s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2"
- s.add_dependency "zeitwerk", "~> 2.1", ">= 2.1.2"
+ s.add_dependency "zeitwerk", "~> 2.1", ">= 2.1.4"
end
diff --git a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb
index d5dc7c2ff4..fd39ad6e55 100644
--- a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb
+++ b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb
@@ -23,8 +23,13 @@ module ActiveSupport
ActiveSupport::Inflector.safe_constantize(cpath)
end
- def to_unload?(cpath)
- Rails.autoloaders.main.to_unload?(cpath)
+ def autoloaded_constants
+ Rails.autoloaders.main.unloadable_cpaths
+ end
+
+ def autoloaded?(object)
+ cpath = object.is_a?(Module) ? object.name : object.to_s
+ Rails.autoloaders.main.unloadable_cpath?(cpath)
end
def verbose=(verbose)
diff --git a/activesupport/lib/active_support/descendants_tracker.rb b/activesupport/lib/active_support/descendants_tracker.rb
index fe0c6991aa..21565138a7 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