Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
32d2a63b
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
32d2a63b
编写于
3月 08, 2019
作者:
X
Xavier Noria
提交者:
GitHub
3月 08, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #35533 from Shopify/zeitwerk-custom-inflectors
Allow autoloader inflectors to be swaped out
上级
199de6be
6d624f2d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
6 deletion
+13
-6
activesupport/lib/active_support/dependencies/zeitwerk_integration.rb
...t/lib/active_support/dependencies/zeitwerk_integration.rb
+0
-4
railties/lib/rails.rb
railties/lib/rails.rb
+1
-0
railties/lib/rails/autoloaders.rb
railties/lib/rails/autoloaders.rb
+8
-2
railties/test/application/configuration_test.rb
railties/test/application/configuration_test.rb
+4
-0
未找到文件。
activesupport/lib/active_support/dependencies/zeitwerk_integration.rb
浏览文件 @
32d2a63b
...
...
@@ -55,10 +55,6 @@ def take_over
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.
...
...
railties/lib/rails.rb
浏览文件 @
32d2a63b
...
...
@@ -6,6 +6,7 @@
require
"active_support"
require
"active_support/dependencies/autoload"
require
"active_support/dependencies/zeitwerk_integration"
require
"active_support/core_ext/kernel/reporting"
require
"active_support/core_ext/module/delegation"
require
"active_support/core_ext/array/extract_options"
...
...
railties/lib/rails/autoloaders.rb
浏览文件 @
32d2a63b
...
...
@@ -7,13 +7,19 @@ class << self
def
main
if
zeitwerk_enabled?
@main
||=
Zeitwerk
::
Loader
.
new
.
tap
{
|
loader
|
loader
.
tag
=
"rails.main"
}
@main
||=
Zeitwerk
::
Loader
.
new
.
tap
do
|
loader
|
loader
.
tag
=
"rails.main"
loader
.
inflector
=
ActiveSupport
::
Dependencies
::
ZeitwerkIntegration
::
Inflector
end
end
end
def
once
if
zeitwerk_enabled?
@once
||=
Zeitwerk
::
Loader
.
new
.
tap
{
|
loader
|
loader
.
tag
=
"rails.once"
}
@once
||=
Zeitwerk
::
Loader
.
new
.
tap
do
|
loader
|
loader
.
tag
=
"rails.once"
loader
.
inflector
=
ActiveSupport
::
Dependencies
::
ZeitwerkIntegration
::
Inflector
end
end
end
...
...
railties/test/application/configuration_test.rb
浏览文件 @
32d2a63b
...
...
@@ -1167,6 +1167,8 @@ def index
assert_instance_of
Zeitwerk
::
Loader
,
Rails
.
autoloaders
.
once
assert_equal
"rails.once"
,
Rails
.
autoloaders
.
once
.
tag
assert_equal
[
Rails
.
autoloaders
.
main
,
Rails
.
autoloaders
.
once
],
Rails
.
autoloaders
.
to_a
assert_equal
ActiveSupport
::
Dependencies
::
ZeitwerkIntegration
::
Inflector
,
Rails
.
autoloaders
.
main
.
inflector
assert_equal
ActiveSupport
::
Dependencies
::
ZeitwerkIntegration
::
Inflector
,
Rails
.
autoloaders
.
once
.
inflector
config
.
autoloader
=
:classic
assert_not
Rails
.
autoloaders
.
zeitwerk_enabled?
...
...
@@ -1181,6 +1183,8 @@ def index
assert_instance_of
Zeitwerk
::
Loader
,
Rails
.
autoloaders
.
once
assert_equal
"rails.once"
,
Rails
.
autoloaders
.
once
.
tag
assert_equal
[
Rails
.
autoloaders
.
main
,
Rails
.
autoloaders
.
once
],
Rails
.
autoloaders
.
to_a
assert_equal
ActiveSupport
::
Dependencies
::
ZeitwerkIntegration
::
Inflector
,
Rails
.
autoloaders
.
main
.
inflector
assert_equal
ActiveSupport
::
Dependencies
::
ZeitwerkIntegration
::
Inflector
,
Rails
.
autoloaders
.
once
.
inflector
assert_raises
(
ArgumentError
)
{
config
.
autoloader
=
:unknown
}
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录