Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
ce97c794
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,发现更多精彩内容 >>
提交
ce97c794
编写于
1月 30, 2017
作者:
R
Rafael França
提交者:
GitHub
1月 30, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #27647 from Shopify/fully-eagerload-journey
Fully initialize routes before the first request is handled
上级
543f1962
5b1332bb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
45 addition
and
1 deletion
+45
-1
actionpack/lib/action_dispatch/journey/path/pattern.rb
actionpack/lib/action_dispatch/journey/path/pattern.rb
+7
-0
actionpack/lib/action_dispatch/journey/route.rb
actionpack/lib/action_dispatch/journey/route.rb
+8
-0
actionpack/lib/action_dispatch/journey/router.rb
actionpack/lib/action_dispatch/journey/router.rb
+7
-0
actionpack/lib/action_dispatch/routing/route_set.rb
actionpack/lib/action_dispatch/routing/route_set.rb
+6
-0
railties/lib/rails/application/finisher.rb
railties/lib/rails/application/finisher.rb
+1
-0
railties/lib/rails/application/routes_reloader.rb
railties/lib/rails/application/routes_reloader.rb
+16
-1
未找到文件。
actionpack/lib/action_dispatch/journey/path/pattern.rb
浏览文件 @
ce97c794
...
...
@@ -31,6 +31,13 @@ def build_formatter
Visitors
::
FormatBuilder
.
new
.
accept
(
spec
)
end
def
eager_load!
required_names
offsets
to_regexp
nil
end
def
ast
@spec
.
find_all
(
&
:symbol?
).
each
do
|
node
|
re
=
@requirements
[
node
.
to_sym
]
...
...
actionpack/lib/action_dispatch/journey/route.rb
浏览文件 @
ce97c794
...
...
@@ -73,6 +73,14 @@ def initialize(name, app, path, constraints, required_defaults, defaults, reques
@internal
=
internal
end
def
eager_load!
path
.
eager_load!
ast
parts
required_defaults
nil
end
def
ast
@decorated_ast
||=
begin
decorated_ast
=
path
.
ast
...
...
actionpack/lib/action_dispatch/journey/router.rb
浏览文件 @
ce97c794
...
...
@@ -22,6 +22,13 @@ def initialize(routes)
@routes
=
routes
end
def
eager_load!
# Eagerly trigger the simulator's initialization so
# it doesn't happen during a request cycle.
simulator
nil
end
def
serve
(
req
)
find_routes
(
req
).
each
do
|
match
,
parameters
,
route
|
set_params
=
req
.
path_parameters
...
...
actionpack/lib/action_dispatch/routing/route_set.rb
浏览文件 @
ce97c794
...
...
@@ -349,6 +349,12 @@ def initialize(config = DEFAULT_CONFIG)
@formatter
=
Journey
::
Formatter
.
new
self
end
def
eager_load!
router
.
eager_load!
routes
.
each
(
&
:eager_load!
)
nil
end
def
relative_url_root
@config
.
relative_url_root
end
...
...
railties/lib/rails/application/finisher.rb
浏览文件 @
ce97c794
...
...
@@ -124,6 +124,7 @@ def self.complete(_state)
# the hook are taken into account.
initializer
:set_routes_reloader_hook
do
|
app
|
reloader
=
routes_reloader
reloader
.
eager_load
=
app
.
config
.
eager_load
reloader
.
execute_if_updated
reloaders
<<
reloader
app
.
reloader
.
to_run
do
...
...
railties/lib/rails/application/routes_reloader.rb
浏览文件 @
ce97c794
...
...
@@ -4,11 +4,13 @@ module Rails
class
Application
class
RoutesReloader
attr_reader
:route_sets
,
:paths
delegate
:execute_if_updated
,
:execute
,
:updated?
,
to: :updater
attr_accessor
:eager_load
delegate
:updated?
,
to: :updater
def
initialize
@paths
=
[]
@route_sets
=
[]
@eager_load
=
false
end
def
reload!
...
...
@@ -19,6 +21,19 @@ def reload!
revert
end
def
execute
ret
=
updater
.
execute
route_sets
.
each
(
&
:eager_load!
)
if
eager_load
ret
end
def
execute_if_updated
if
updated
=
updater
.
execute_if_updated
route_sets
.
each
(
&
:eager_load!
)
if
eager_load
end
updated
end
private
def
updater
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录