Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
288e947a
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,发现更多精彩内容 >>
提交
288e947a
编写于
9月 02, 2008
作者:
C
Clemens Kofler
提交者:
Jeremy Kemper
9月 03, 2008
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some performance goodness for inheritable attributes.
Signed-off-by:
N
Jeremy Kemper
<
jeremy@bitsweat.net
>
上级
4d092ba2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
17 deletion
+17
-17
actionpack/lib/action_controller/layout.rb
actionpack/lib/action_controller/layout.rb
+6
-6
actionpack/lib/action_controller/session_management.rb
actionpack/lib/action_controller/session_management.rb
+2
-2
activerecord/lib/active_record/base.rb
activerecord/lib/active_record/base.rb
+7
-7
activeresource/lib/active_resource/base.rb
activeresource/lib/active_resource/base.rb
+2
-2
未找到文件。
actionpack/lib/action_controller/layout.rb
浏览文件 @
288e947a
...
@@ -164,17 +164,17 @@ module ClassMethods
...
@@ -164,17 +164,17 @@ module ClassMethods
# performance and have access to them as any normal template would.
# performance and have access to them as any normal template would.
def
layout
(
template_name
,
conditions
=
{},
auto
=
false
)
def
layout
(
template_name
,
conditions
=
{},
auto
=
false
)
add_layout_conditions
(
conditions
)
add_layout_conditions
(
conditions
)
write_inheritable_attribute
"layout"
,
template_name
write_inheritable_attribute
(
:layout
,
template_name
)
write_inheritable_attribute
"auto_layout"
,
auto
write_inheritable_attribute
(
:auto_layout
,
auto
)
end
end
def
layout_conditions
#:nodoc:
def
layout_conditions
#:nodoc:
@layout_conditions
||=
read_inheritable_attribute
(
"layout_conditions"
)
@layout_conditions
||=
read_inheritable_attribute
(
:layout_conditions
)
end
end
def
default_layout
(
format
)
#:nodoc:
def
default_layout
(
format
)
#:nodoc:
layout
=
read_inheritable_attribute
(
"layout"
)
layout
=
read_inheritable_attribute
(
:layout
)
return
layout
unless
read_inheritable_attribute
(
"auto_layout"
)
return
layout
unless
read_inheritable_attribute
(
:auto_layout
)
@default_layout
||=
{}
@default_layout
||=
{}
@default_layout
[
format
]
||=
default_layout_with_format
(
format
,
layout
)
@default_layout
[
format
]
||=
default_layout_with_format
(
format
,
layout
)
@default_layout
[
format
]
@default_layout
[
format
]
...
@@ -194,7 +194,7 @@ def inherited_with_layout(child)
...
@@ -194,7 +194,7 @@ def inherited_with_layout(child)
end
end
def
add_layout_conditions
(
conditions
)
def
add_layout_conditions
(
conditions
)
write_inheritable_hash
"layout_conditions"
,
normalize_conditions
(
conditions
)
write_inheritable_hash
(
:layout_conditions
,
normalize_conditions
(
conditions
)
)
end
end
def
normalize_conditions
(
conditions
)
def
normalize_conditions
(
conditions
)
...
...
actionpack/lib/action_controller/session_management.rb
浏览文件 @
288e947a
...
@@ -86,14 +86,14 @@ def session(*args)
...
@@ -86,14 +86,14 @@ def session(*args)
raise
ArgumentError
,
"only one of either :only or :except are allowed"
raise
ArgumentError
,
"only one of either :only or :except are allowed"
end
end
write_inheritable_array
(
"session_options"
,
[
options
])
write_inheritable_array
(
:session_options
,
[
options
])
end
end
# So we can declare session options in the Rails initializer.
# So we can declare session options in the Rails initializer.
alias_method
:session
=
,
:session
alias_method
:session
=
,
:session
def
cached_session_options
#:nodoc:
def
cached_session_options
#:nodoc:
@session_options
||=
read_inheritable_attribute
(
"session_options"
)
||
[]
@session_options
||=
read_inheritable_attribute
(
:session_options
)
||
[]
end
end
def
session_options_for
(
request
,
action
)
#:nodoc:
def
session_options_for
(
request
,
action
)
#:nodoc:
...
...
activerecord/lib/active_record/base.rb
浏览文件 @
288e947a
...
@@ -920,12 +920,12 @@ def decrement_counter(counter_name, id)
...
@@ -920,12 +920,12 @@ def decrement_counter(counter_name, id)
# To start from an all-closed default and enable attributes as needed,
# To start from an all-closed default and enable attributes as needed,
# have a look at +attr_accessible+.
# have a look at +attr_accessible+.
def
attr_protected
(
*
attributes
)
def
attr_protected
(
*
attributes
)
write_inheritable_attribute
(
"attr_protected"
,
Set
.
new
(
attributes
.
map
(
&
:to_s
))
+
(
protected_attributes
||
[]))
write_inheritable_attribute
(
:attr_protected
,
Set
.
new
(
attributes
.
map
(
&
:to_s
))
+
(
protected_attributes
||
[]))
end
end
# Returns an array of all the attributes that have been protected from mass-assignment.
# Returns an array of all the attributes that have been protected from mass-assignment.
def
protected_attributes
# :nodoc:
def
protected_attributes
# :nodoc:
read_inheritable_attribute
(
"attr_protected"
)
read_inheritable_attribute
(
:attr_protected
)
end
end
# Specifies a white list of model attributes that can be set via
# Specifies a white list of model attributes that can be set via
...
@@ -953,22 +953,22 @@ def protected_attributes # :nodoc:
...
@@ -953,22 +953,22 @@ def protected_attributes # :nodoc:
# customer.credit_rating = "Average"
# customer.credit_rating = "Average"
# customer.credit_rating # => "Average"
# customer.credit_rating # => "Average"
def
attr_accessible
(
*
attributes
)
def
attr_accessible
(
*
attributes
)
write_inheritable_attribute
(
"attr_accessible"
,
Set
.
new
(
attributes
.
map
(
&
:to_s
))
+
(
accessible_attributes
||
[]))
write_inheritable_attribute
(
:attr_accessible
,
Set
.
new
(
attributes
.
map
(
&
:to_s
))
+
(
accessible_attributes
||
[]))
end
end
# Returns an array of all the attributes that have been made accessible to mass-assignment.
# Returns an array of all the attributes that have been made accessible to mass-assignment.
def
accessible_attributes
# :nodoc:
def
accessible_attributes
# :nodoc:
read_inheritable_attribute
(
"attr_accessible"
)
read_inheritable_attribute
(
:attr_accessible
)
end
end
# Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards.
# Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards.
def
attr_readonly
(
*
attributes
)
def
attr_readonly
(
*
attributes
)
write_inheritable_attribute
(
"attr_readonly"
,
Set
.
new
(
attributes
.
map
(
&
:to_s
))
+
(
readonly_attributes
||
[]))
write_inheritable_attribute
(
:attr_readonly
,
Set
.
new
(
attributes
.
map
(
&
:to_s
))
+
(
readonly_attributes
||
[]))
end
end
# Returns an array of all the attributes that have been specified as readonly.
# Returns an array of all the attributes that have been specified as readonly.
def
readonly_attributes
def
readonly_attributes
read_inheritable_attribute
(
"attr_readonly"
)
read_inheritable_attribute
(
:attr_readonly
)
end
end
# If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object,
# If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object,
...
@@ -992,7 +992,7 @@ def serialize(attr_name, class_name = Object)
...
@@ -992,7 +992,7 @@ def serialize(attr_name, class_name = Object)
# Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values.
# Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values.
def
serialized_attributes
def
serialized_attributes
read_inheritable_attribute
(
"attr_serialized"
)
or
write_inheritable_attribute
(
"attr_serialized"
,
{})
read_inheritable_attribute
(
:attr_serialized
)
or
write_inheritable_attribute
(
:attr_serialized
,
{})
end
end
...
...
activeresource/lib/active_resource/base.rb
浏览文件 @
288e947a
...
@@ -283,13 +283,13 @@ def format=(mime_type_reference_or_format)
...
@@ -283,13 +283,13 @@ def format=(mime_type_reference_or_format)
format
=
mime_type_reference_or_format
.
is_a?
(
Symbol
)
?
format
=
mime_type_reference_or_format
.
is_a?
(
Symbol
)
?
ActiveResource
::
Formats
[
mime_type_reference_or_format
]
:
mime_type_reference_or_format
ActiveResource
::
Formats
[
mime_type_reference_or_format
]
:
mime_type_reference_or_format
write_inheritable_attribute
(
"format"
,
format
)
write_inheritable_attribute
(
:format
,
format
)
connection
.
format
=
format
if
site
connection
.
format
=
format
if
site
end
end
# Returns the current format, default is ActiveResource::Formats::XmlFormat.
# Returns the current format, default is ActiveResource::Formats::XmlFormat.
def
format
def
format
read_inheritable_attribute
(
"format"
)
||
ActiveResource
::
Formats
[
:xml
]
read_inheritable_attribute
(
:format
)
||
ActiveResource
::
Formats
[
:xml
]
end
end
# Sets the number of seconds after which requests to the REST API should time out.
# Sets the number of seconds after which requests to the REST API should time out.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录