Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
1722397f
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,发现更多精彩内容 >>
提交
1722397f
编写于
9月 06, 2016
作者:
X
Xavier Noria
提交者:
GitHub
9月 06, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26405 from alexcameron89/case_statement_formatting
Fix Remaining Case-In-Assignment Statement Formatting
上级
2e4eb039
fbccae4d
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
123 addition
and
113 deletion
+123
-113
actionview/lib/action_view/helpers/date_helper.rb
actionview/lib/action_view/helpers/date_helper.rb
+9
-8
actionview/lib/action_view/helpers/form_tag_helper.rb
actionview/lib/action_view/helpers/form_tag_helper.rb
+17
-16
activemodel/lib/active_model/type/decimal.rb
activemodel/lib/active_model/type/decimal.rb
+13
-12
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+17
-16
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
...ecord/connection_adapters/postgresql/schema_statements.rb
+26
-25
activerecord/lib/active_record/nested_attributes.rb
activerecord/lib/active_record/nested_attributes.rb
+9
-8
activerecord/lib/active_record/relation/query_methods.rb
activerecord/lib/active_record/relation/query_methods.rb
+6
-5
activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
...cord/lib/active_record/tasks/postgresql_database_tasks.rb
+9
-8
activesupport/lib/active_support/i18n_railtie.rb
activesupport/lib/active_support/i18n_railtie.rb
+9
-8
railties/lib/rails/generators/app_base.rb
railties/lib/rails/generators/app_base.rb
+8
-7
未找到文件。
actionview/lib/action_view/helpers/date_helper.rb
浏览文件 @
1722397f
...
...
@@ -1026,15 +1026,16 @@ def css_class_attribute(type, html_options_class, options) # :nodoc:
# prompt_option_tag(:month, prompt: 'Select month')
# => "<option value="">Select month</option>"
def
prompt_option_tag
(
type
,
options
)
prompt
=
case
options
when
Hash
default_options
=
{
year:
false
,
month:
false
,
day:
false
,
hour:
false
,
minute:
false
,
second:
false
}
default_options
.
merge!
(
options
)[
type
.
to_sym
]
when
String
options
prompt
=
\
case
options
when
Hash
default_options
=
{
year:
false
,
month:
false
,
day:
false
,
hour:
false
,
minute:
false
,
second:
false
}
default_options
.
merge!
(
options
)[
type
.
to_sym
]
when
String
options
else
I18n
.
translate
(
:"datetime.prompts.
#{
type
}
"
,
locale:
@options
[
:locale
])
end
I18n
.
translate
(
:"datetime.prompts.
#{
type
}
"
,
locale:
@options
[
:locale
])
end
prompt
?
content_tag
(
"option"
.
freeze
,
prompt
,
value:
""
)
:
""
end
...
...
actionview/lib/action_view/helpers/form_tag_helper.rb
浏览文件 @
1722397f
...
...
@@ -857,23 +857,24 @@ def extra_tags_for_form(html_options)
authenticity_token
=
html_options
.
delete
(
"authenticity_token"
)
method
=
html_options
.
delete
(
"method"
).
to_s
.
downcase
method_tag
=
case
method
when
"get"
html_options
[
"method"
]
=
"get"
""
when
"post"
,
""
html_options
[
"method"
]
=
"post"
token_tag
(
authenticity_token
,
form_options:
{
action:
html_options
[
"action"
],
method:
"post"
})
method_tag
=
\
case
method
when
"get"
html_options
[
"method"
]
=
"get"
""
when
"post"
,
""
html_options
[
"method"
]
=
"post"
token_tag
(
authenticity_token
,
form_options:
{
action:
html_options
[
"action"
],
method:
"post"
})
else
html_options
[
"method"
]
=
"post"
method_tag
(
method
)
+
token_tag
(
authenticity_token
,
form_options:
{
action:
html_options
[
"action"
],
method:
method
})
end
html_options
[
"method"
]
=
"post"
method_tag
(
method
)
+
token_tag
(
authenticity_token
,
form_options:
{
action:
html_options
[
"action"
],
method:
method
})
end
if
html_options
.
delete
(
"enforce_utf8"
)
{
true
}
utf8_enforcer_tag
+
method_tag
...
...
activemodel/lib/active_model/type/decimal.rb
浏览文件 @
1722397f
...
...
@@ -16,18 +16,19 @@ def type_cast_for_schema(value)
private
def
cast_value
(
value
)
casted_value
=
case
value
when
::
Float
convert_float_to_big_decimal
(
value
)
when
::
Numeric
,
::
String
BigDecimal
(
value
,
precision
.
to_i
)
else
if
value
.
respond_to?
(
:to_d
)
value
.
to_d
else
cast_value
(
value
.
to_s
)
end
end
casted_value
=
\
case
value
when
::
Float
convert_float_to_big_decimal
(
value
)
when
::
Numeric
,
::
String
BigDecimal
(
value
,
precision
.
to_i
)
else
if
value
.
respond_to?
(
:to_d
)
value
.
to_d
else
cast_value
(
value
.
to_s
)
end
end
apply_scale
(
casted_value
)
end
...
...
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
1722397f
...
...
@@ -570,22 +570,23 @@ def table_options(table_name) # :nodoc:
# Maps logical Rails types to MySQL-specific data types.
def
type_to_sql
(
type
,
limit
=
nil
,
precision
=
nil
,
scale
=
nil
,
unsigned
=
nil
)
sql
=
case
type
.
to_s
when
"integer"
integer_to_sql
(
limit
)
when
"text"
text_to_sql
(
limit
)
when
"blob"
binary_to_sql
(
limit
)
when
"binary"
if
(
0
..
0xfff
)
===
limit
"varbinary(
#{
limit
}
)"
else
binary_to_sql
(
limit
)
end
else
super
(
type
,
limit
,
precision
,
scale
)
end
sql
=
\
case
type
.
to_s
when
"integer"
integer_to_sql
(
limit
)
when
"text"
text_to_sql
(
limit
)
when
"blob"
binary_to_sql
(
limit
)
when
"binary"
if
(
0
..
0xfff
)
===
limit
"varbinary(
#{
limit
}
)"
else
binary_to_sql
(
limit
)
end
else
super
(
type
,
limit
,
precision
,
scale
)
end
sql
<<
" unsigned"
if
unsigned
&&
type
!=
:primary_key
sql
...
...
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
浏览文件 @
1722397f
...
...
@@ -625,31 +625,32 @@ def index_name_length
# Maps logical Rails types to PostgreSQL-specific data types.
def
type_to_sql
(
type
,
limit
=
nil
,
precision
=
nil
,
scale
=
nil
,
array
=
nil
)
sql
=
case
type
.
to_s
when
"binary"
# PostgreSQL doesn't support limits on binary (bytea) columns.
# The hard limit is 1GB, because of a 32-bit size field, and TOAST.
case
limit
when
nil
,
0
..
0x3fffffff
;
super
(
type
)
else
raise
(
ActiveRecordError
,
"No binary type has byte size
#{
limit
}
."
)
end
when
"text"
# PostgreSQL doesn't support limits on text columns.
# The hard limit is 1GB, according to section 8.3 in the manual.
case
limit
when
nil
,
0
..
0x3fffffff
;
super
(
type
)
else
raise
(
ActiveRecordError
,
"The limit on text can be at most 1GB - 1byte."
)
end
when
"integer"
case
limit
when
1
,
2
;
"smallint"
when
nil
,
3
,
4
;
"integer"
when
5
..
8
;
"bigint"
else
raise
(
ActiveRecordError
,
"No integer type has byte size
#{
limit
}
. Use a numeric with scale 0 instead."
)
end
else
super
(
type
,
limit
,
precision
,
scale
)
end
sql
=
\
case
type
.
to_s
when
"binary"
# PostgreSQL doesn't support limits on binary (bytea) columns.
# The hard limit is 1GB, because of a 32-bit size field, and TOAST.
case
limit
when
nil
,
0
..
0x3fffffff
;
super
(
type
)
else
raise
(
ActiveRecordError
,
"No binary type has byte size
#{
limit
}
."
)
end
when
"text"
# PostgreSQL doesn't support limits on text columns.
# The hard limit is 1GB, according to section 8.3 in the manual.
case
limit
when
nil
,
0
..
0x3fffffff
;
super
(
type
)
else
raise
(
ActiveRecordError
,
"The limit on text can be at most 1GB - 1byte."
)
end
when
"integer"
case
limit
when
1
,
2
;
"smallint"
when
nil
,
3
,
4
;
"integer"
when
5
..
8
;
"bigint"
else
raise
(
ActiveRecordError
,
"No integer type has byte size
#{
limit
}
. Use a numeric with scale 0 instead."
)
end
else
super
(
type
,
limit
,
precision
,
scale
)
end
sql
<<
"[]"
if
array
&&
type
!=
:primary_key
sql
...
...
activerecord/lib/active_record/nested_attributes.rb
浏览文件 @
1722397f
...
...
@@ -519,14 +519,15 @@ def assign_nested_attributes_for_collection_association(association_name, attrib
# larger than the limit.
def
check_record_limit!
(
limit
,
attributes_collection
)
if
limit
limit
=
case
limit
when
Symbol
send
(
limit
)
when
Proc
limit
.
call
else
limit
end
limit
=
\
case
limit
when
Symbol
send
(
limit
)
when
Proc
limit
.
call
else
limit
end
if
limit
&&
attributes_collection
.
size
>
limit
raise
TooManyRecords
,
"Maximum
#{
limit
}
records are allowed. Got
#{
attributes_collection
.
size
}
records instead."
...
...
activerecord/lib/active_record/relation/query_methods.rb
浏览文件 @
1722397f
...
...
@@ -59,11 +59,12 @@ def not(opts, *rest)
FROZEN_EMPTY_HASH
=
{}.
freeze
Relation
::
VALUE_METHODS
.
each
do
|
name
|
method_name
=
case
name
when
*
Relation
::
MULTI_VALUE_METHODS
then
"
#{
name
}
_values"
when
*
Relation
::
SINGLE_VALUE_METHODS
then
"
#{
name
}
_value"
when
*
Relation
::
CLAUSE_METHODS
then
"
#{
name
}
_clause"
end
method_name
=
\
case
name
when
*
Relation
::
MULTI_VALUE_METHODS
then
"
#{
name
}
_values"
when
*
Relation
::
SINGLE_VALUE_METHODS
then
"
#{
name
}
_value"
when
*
Relation
::
CLAUSE_METHODS
then
"
#{
name
}
_clause"
end
class_eval
<<-
CODE
,
__FILE__
,
__LINE__
+
1
def
#{
method_name
}
# def includes_values
get_value(
#{
name
.
inspect
}
) # get_value(:includes)
...
...
activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
浏览文件 @
1722397f
...
...
@@ -46,14 +46,15 @@ def purge
def
structure_dump
(
filename
)
set_psql_env
search_path
=
case
ActiveRecord
::
Base
.
dump_schemas
when
:schema_search_path
configuration
[
"schema_search_path"
]
when
:all
nil
when
String
ActiveRecord
::
Base
.
dump_schemas
end
search_path
=
\
case
ActiveRecord
::
Base
.
dump_schemas
when
:schema_search_path
configuration
[
"schema_search_path"
]
when
:all
nil
when
String
ActiveRecord
::
Base
.
dump_schemas
end
args
=
[
"-s"
,
"-x"
,
"-O"
,
"-f"
,
filename
]
unless
search_path
.
blank?
...
...
activesupport/lib/active_support/i18n_railtie.rb
浏览文件 @
1722397f
...
...
@@ -83,14 +83,15 @@ def self.include_fallbacks_module
def
self
.
init_fallbacks
(
fallbacks
)
include_fallbacks_module
args
=
case
fallbacks
when
ActiveSupport
::
OrderedOptions
[
*
(
fallbacks
[
:defaults
]
||
[])
<<
fallbacks
[
:map
]].
compact
when
Hash
,
Array
Array
.
wrap
(
fallbacks
)
else
# TrueClass
[]
end
args
=
\
case
fallbacks
when
ActiveSupport
::
OrderedOptions
[
*
(
fallbacks
[
:defaults
]
||
[])
<<
fallbacks
[
:map
]].
compact
when
Hash
,
Array
Array
.
wrap
(
fallbacks
)
else
# TrueClass
[]
end
I18n
.
fallbacks
=
I18n
::
Locale
::
Fallbacks
.
new
(
*
args
)
end
...
...
railties/lib/rails/generators/app_base.rb
浏览文件 @
1722397f
...
...
@@ -162,14 +162,15 @@ def apply_rails_template
def
set_default_accessors!
self
.
destination_root
=
File
.
expand_path
(
app_path
,
destination_root
)
self
.
rails_template
=
case
options
[
:template
]
when
/^https?:\/\//
options
[
:template
]
when
String
File
.
expand_path
(
options
[
:template
],
Dir
.
pwd
)
self
.
rails_template
=
\
case
options
[
:template
]
when
/^https?:\/\//
options
[
:template
]
when
String
File
.
expand_path
(
options
[
:template
],
Dir
.
pwd
)
else
options
[
:template
]
end
options
[
:template
]
end
end
def
database_gemfile_entry
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录