diff options
author | Xavier Noria <fxn@hashref.com> | 2019-02-23 14:37:20 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2019-02-23 14:37:20 -0800 |
commit | 39b2a6374b49dba43606b1a806899e49aa055a81 (patch) | |
tree | e5bb4b761f19e9cd37947a87b25ad2b0c7ec5b10 /activesupport/lib/active_support/dependencies | |
parent | 4d9ba8b50b0ff01d19ff786aa64c9da0fb31aa7e (diff) | |
download | rails-39b2a6374b49dba43606b1a806899e49aa055a81.tar.gz rails-39b2a6374b49dba43606b1a806899e49aa055a81.tar.bz2 rails-39b2a6374b49dba43606b1a806899e49aa055a81.zip |
Let Zeitwerk autoloaders inflect with Active Support
[Harry Brundage & Xavier Noria]
Diffstat (limited to 'activesupport/lib/active_support/dependencies')
-rw-r--r-- | activesupport/lib/active_support/dependencies/zeitwerk_integration.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb index 297bde5534..ca4385b7c2 100644 --- a/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb +++ b/activesupport/lib/active_support/dependencies/zeitwerk_integration.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/string/inflections" + module ActiveSupport module Dependencies module ZeitwerkIntegration # :nodoc: all @@ -11,11 +13,11 @@ module ActiveSupport end def constantize(cpath) - Inflector.constantize(cpath) + ActiveSupport::Inflector.constantize(cpath) end def safe_constantize(cpath) - Inflector.safe_constantize(cpath) + ActiveSupport::Inflector.safe_constantize(cpath) end def autoloaded_constants @@ -37,6 +39,12 @@ module ActiveSupport end end + module Inflector + def self.camelize(basename, _abspath) + basename.camelize + end + end + class << self def take_over setup_autoloaders @@ -47,6 +55,10 @@ module ActiveSupport private def setup_autoloaders + Rails.autoloaders.each do |autoloader| + autoloader.inflector = Inflector + end + Dependencies.autoload_paths.each do |autoload_path| # Zeitwerk only accepts existing directories in `push_dir` to # prevent misconfigurations. |