Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
56f3bbc5
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,发现更多精彩内容 >>
提交
56f3bbc5
编写于
3月 01, 2016
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23936 from yui-knk/local_constants_to_be_public
Deprecate `Module.local_constants`
上级
bc57930e
86d4e189
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
26 deletion
+17
-26
activesupport/CHANGELOG.md
activesupport/CHANGELOG.md
+4
-0
activesupport/lib/active_support/core_ext/module/introspection.rb
...pport/lib/active_support/core_ext/module/introspection.rb
+4
-0
activesupport/lib/active_support/dependencies.rb
activesupport/lib/active_support/dependencies.rb
+2
-2
activesupport/test/core_ext/module_test.rb
activesupport/test/core_ext/module_test.rb
+7
-1
guides/source/active_support_core_extensions.md
guides/source/active_support_core_extensions.md
+0
-23
未找到文件。
activesupport/CHANGELOG.md
浏览文件 @
56f3bbc5
*
Deprecate
`Module.local_constants`
. Please use
`Module.constants(false)`
instead.
*Yuichiro Kaneko*
*
Publish ActiveSupport::Executor and ActiveSupport::Reloader APIs to allow
components and libraries to manage, and participate in, the execution of
application code, and the application reloading process.
...
...
activesupport/lib/active_support/core_ext/module/introspection.rb
浏览文件 @
56f3bbc5
...
...
@@ -57,6 +57,10 @@ def parents
end
def
local_constants
#:nodoc:
ActiveSupport
::
Deprecation
.
warn
(
<<-
MSG
.
squish
)
Module#local_constants is deprecated and will be removed in Rails 5.1.
Use Module#constants(false) instead.
MSG
constants
(
false
)
end
end
activesupport/lib/active_support/dependencies.rb
浏览文件 @
56f3bbc5
...
...
@@ -143,7 +143,7 @@ def new_constants
next
unless
mod
.
is_a?
(
Module
)
# Get a list of the constants that were added
new_constants
=
mod
.
local_constants
-
original_constants
new_constants
=
mod
.
constants
(
false
)
-
original_constants
# @stack[namespace] returns an Array of the constants that are being evaluated
# for that namespace. For instance, if parent.rb requires child.rb, the first
...
...
@@ -171,7 +171,7 @@ def watch_namespaces(namespaces)
@watching
<<
namespaces
.
map
do
|
namespace
|
module_name
=
Dependencies
.
to_constant_name
(
namespace
)
original_constants
=
Dependencies
.
qualified_const_defined?
(
module_name
)
?
Inflector
.
constantize
(
module_name
).
local_constants
:
[]
Inflector
.
constantize
(
module_name
).
constants
(
false
)
:
[]
@stack
[
module_name
]
<<
original_constants
module_name
...
...
activesupport/test/core_ext/module_test.rb
浏览文件 @
56f3bbc5
...
...
@@ -328,7 +328,13 @@ def test_parents
end
def
test_local_constants
assert_equal
%w(Constant1 Constant3)
,
Ab
.
local_constants
.
sort
.
map
(
&
:to_s
)
ActiveSupport
::
Deprecation
.
silence
do
assert_equal
%w(Constant1 Constant3)
,
Ab
.
local_constants
.
sort
.
map
(
&
:to_s
)
end
end
def
test_test_local_constants_is_deprecated
assert_deprecated
{
Ab
.
local_constants
.
sort
.
map
(
&
:to_s
)
}
end
end
...
...
guides/source/active_support_core_extensions.md
浏览文件 @
56f3bbc5
...
...
@@ -709,29 +709,6 @@ M.parents # => [X::Y, X, Object]
NOTE: Defined in
`active_support/core_ext/module/introspection.rb`
.
### Constants
The method
`local_constants`
returns the names of the constants that have been
defined in the receiver module:
```
ruby
module
X
X1
=
1
X2
=
2
module
Y
Y1
=
:y1
X1
=
:overrides_X1_above
end
end
X
.
local_constants
# => [:X1, :X2, :Y]
X
::
Y
.
local_constants
# => [:Y1, :X1]
```
The names are returned as symbols.
NOTE: Defined in
`active_support/core_ext/module/introspection.rb`
.
#### Qualified Constant Names
The standard methods
`const_defined?`
,
`const_get`
, and
`const_set`
accept
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录