Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
86dda361
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,发现更多精彩内容 >>
提交
86dda361
编写于
4月 10, 2010
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid deprecated String#to_a by using Array.wrap(...) instead of Array(...)
上级
61355c0e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
24 addition
and
12 deletion
+24
-12
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations.rb
+4
-3
activerecord/lib/active_record/associations/association_collection.rb
.../lib/active_record/associations/association_collection.rb
+2
-1
activerecord/lib/active_record/associations/association_proxy.rb
...ecord/lib/active_record/associations/association_proxy.rb
+3
-1
activerecord/lib/active_record/callbacks.rb
activerecord/lib/active_record/callbacks.rb
+4
-2
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
..._record/connection_adapters/abstract/schema_statements.rb
+4
-2
activerecord/lib/active_record/relation/query_methods.rb
activerecord/lib/active_record/relation/query_methods.rb
+2
-1
activerecord/lib/active_record/serializers/xml_serializer.rb
activerecord/lib/active_record/serializers/xml_serializer.rb
+2
-1
activerecord/lib/active_record/validations/uniqueness.rb
activerecord/lib/active_record/validations/uniqueness.rb
+3
-1
未找到文件。
activerecord/lib/active_record/associations.rb
浏览文件 @
86dda361
require
'active_support/core_ext/
module/delegation
'
require
'active_support/core_ext/
array/wrap
'
require
'active_support/core_ext/enumerable'
require
'active_support/core_ext/module/delegation'
require
'active_support/core_ext/object/blank'
module
ActiveRecord
...
...
@@ -1707,9 +1708,9 @@ def create_extension_modules(association_id, block_extension, extensions)
silence_warnings
do
self
.
parent
.
const_set
(
extension_module_name
,
Module
.
new
(
&
block_extension
))
end
Array
(
extensions
).
push
(
"
#{
self
.
parent
}
::
#{
extension_module_name
}
"
.
constantize
)
Array
.
wrap
(
extensions
).
push
(
"
#{
self
.
parent
}
::
#{
extension_module_name
}
"
.
constantize
)
else
Array
(
extensions
)
Array
.
wrap
(
extensions
)
end
end
...
...
activerecord/lib/active_record/associations/association_collection.rb
浏览文件 @
86dda361
require
'set'
require
'active_support/core_ext/array/wrap'
module
ActiveRecord
module
Associations
...
...
@@ -98,7 +99,7 @@ def to_ary
if
@target
.
is_a?
(
Array
)
@target
.
to_ary
else
Array
(
@target
)
Array
.
wrap
(
@target
)
end
end
alias_method
:to_a
,
:to_ary
...
...
activerecord/lib/active_record/associations/association_proxy.rb
浏览文件 @
86dda361
require
'active_support/core_ext/array/wrap'
module
ActiveRecord
module
Associations
# This is the root class of all association proxies:
...
...
@@ -55,7 +57,7 @@ def initialize(owner, reflection)
@owner
,
@reflection
=
owner
,
reflection
@updated
=
false
reflection
.
check_validity!
Array
(
reflection
.
options
[
:extend
]).
each
{
|
ext
|
proxy_extend
(
ext
)
}
Array
.
wrap
(
reflection
.
options
[
:extend
]).
each
{
|
ext
|
proxy_extend
(
ext
)
}
reset
end
...
...
activerecord/lib/active_record/callbacks.rb
浏览文件 @
86dda361
require
'active_support/core_ext/array/wrap'
module
ActiveRecord
# Callbacks are hooks into the lifecycle of an Active Record object that allow you to trigger logic
# before or after an alteration of the object state. This can be used to make sure that associated and
...
...
@@ -250,7 +252,7 @@ def method_added(meth)
def
before_validation
(
*
args
,
&
block
)
options
=
args
.
last
if
options
.
is_a?
(
Hash
)
&&
options
[
:on
]
options
[
:if
]
=
Array
(
options
[
:if
])
options
[
:if
]
=
Array
.
wrap
(
options
[
:if
])
options
[
:if
]
<<
"@_on_validate == :
#{
options
[
:on
]
}
"
end
set_callback
(
:validation
,
:before
,
*
args
,
&
block
)
...
...
@@ -259,7 +261,7 @@ def before_validation(*args, &block)
def
after_validation
(
*
args
,
&
block
)
options
=
args
.
extract_options!
options
[
:prepend
]
=
true
options
[
:if
]
=
Array
(
options
[
:if
])
options
[
:if
]
=
Array
.
wrap
(
options
[
:if
])
options
[
:if
]
<<
"!halted && value != false"
options
[
:if
]
<<
"@_on_validate == :
#{
options
[
:on
]
}
"
if
options
[
:on
]
set_callback
(
:validation
,
:after
,
*
(
args
<<
options
),
&
block
)
...
...
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
浏览文件 @
86dda361
require
'active_support/core_ext/array/wrap'
module
ActiveRecord
module
ConnectionAdapters
# :nodoc:
module
SchemaStatements
...
...
@@ -267,7 +269,7 @@ def rename_column(table_name, column_name, new_column_name)
# generates
# CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id)
def
add_index
(
table_name
,
column_name
,
options
=
{})
column_names
=
Array
(
column_name
)
column_names
=
Array
.
wrap
(
column_name
)
index_name
=
index_name
(
table_name
,
:column
=>
column_names
)
if
Hash
===
options
# legacy support, since this param was a string
...
...
@@ -297,7 +299,7 @@ def remove_index(table_name, options = {})
def
index_name
(
table_name
,
options
)
#:nodoc:
if
Hash
===
options
# legacy support
if
options
[
:column
]
"index_
#{
table_name
}
_on_
#{
Array
(
options
[
:column
])
*
'_and_'
}
"
"index_
#{
table_name
}
_on_
#{
Array
.
wrap
(
options
[
:column
])
*
'_and_'
}
"
elsif
options
[
:name
]
options
[
:name
]
else
...
...
activerecord/lib/active_record/relation/query_methods.rb
浏览文件 @
86dda361
require
'active_support/core_ext/array/wrap'
require
'active_support/core_ext/object/blank'
module
ActiveRecord
...
...
@@ -26,7 +27,7 @@ def #{query_method}(*args, &block)
new_relation = clone
new_relation.send(:apply_modules, Module.new(&block)) if block_given?
value = build_where(*args)
new_relation.
#{
query_method
}
_values +=
[*value]
if value.present?
new_relation.
#{
query_method
}
_values +=
Array.wrap(value)
if value.present?
new_relation
end
CEVAL
...
...
activerecord/lib/active_record/serializers/xml_serializer.rb
浏览文件 @
86dda361
require
'active_support/core_ext/array/wrap'
require
'active_support/core_ext/hash/conversions'
module
ActiveRecord
#:nodoc:
...
...
@@ -186,7 +187,7 @@ def serializable_attributes
end
def
serializable_method_attributes
Array
(
options
[
:methods
]).
inject
([])
do
|
method_attributes
,
name
|
Array
.
wrap
(
options
[
:methods
]).
inject
([])
do
|
method_attributes
,
name
|
method_attributes
<<
MethodAttribute
.
new
(
name
.
to_s
,
@serializable
)
if
@serializable
.
respond_to?
(
name
.
to_s
)
method_attributes
end
...
...
activerecord/lib/active_record/validations/uniqueness.rb
浏览文件 @
86dda361
require
'active_support/core_ext/array/wrap'
module
ActiveRecord
module
Validations
class
UniquenessValidator
<
ActiveModel
::
EachValidator
...
...
@@ -19,7 +21,7 @@ def validate_each(record, attribute, value)
relation
=
table
.
where
(
sql
,
*
params
)
Array
(
options
[
:scope
]).
each
do
|
scope_item
|
Array
.
wrap
(
options
[
:scope
]).
each
do
|
scope_item
|
scope_value
=
record
.
send
(
scope_item
)
relation
=
relation
.
where
(
scope_item
=>
scope_value
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录