Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
001c8beb
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,发现更多精彩内容 >>
提交
001c8beb
编写于
7月 14, 2008
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
memorize typo
上级
dd41f66a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
15 deletion
+15
-15
actionpack/lib/action_view/renderable.rb
actionpack/lib/action_view/renderable.rb
+2
-2
actionpack/lib/action_view/renderable_partial.rb
actionpack/lib/action_view/renderable_partial.rb
+2
-2
actionpack/lib/action_view/template.rb
actionpack/lib/action_view/template.rb
+6
-6
activesupport/lib/active_support/memoizable.rb
activesupport/lib/active_support/memoizable.rb
+3
-3
activesupport/test/memoizable_test.rb
activesupport/test/memoizable_test.rb
+2
-2
未找到文件。
actionpack/lib/action_view/renderable.rb
浏览文件 @
001c8beb
...
...
@@ -12,12 +12,12 @@ def self.included(base)
def
handler
Template
.
handler_class_for_extension
(
extension
)
end
memo
r
ize
:handler
memoize
:handler
def
compiled_source
handler
.
new
(
nil
).
compile
(
self
)
if
handler
.
compilable?
end
memo
r
ize
:compiled_source
memoize
:compiled_source
def
render
(
view
,
local_assigns
=
{})
view
.
_first_render
||=
self
...
...
actionpack/lib/action_view/renderable_partial.rb
浏览文件 @
001c8beb
...
...
@@ -8,12 +8,12 @@ module RenderablePartial
def
variable_name
name
.
sub
(
/\A_/
,
''
).
to_sym
end
memo
r
ize
:variable_name
memoize
:variable_name
def
counter_name
"
#{
variable_name
}
_counter"
.
to_sym
end
memo
r
ize
:counter_name
memoize
:counter_name
def
render
(
view
,
local_assigns
=
{})
ActionController
::
Base
.
benchmark
(
"Rendered
#{
path_without_format_and_extension
}
"
,
Logger
::
DEBUG
,
false
)
do
...
...
actionpack/lib/action_view/template.rb
浏览文件 @
001c8beb
...
...
@@ -20,34 +20,34 @@ def initialize(template_path, load_paths = [])
def
format_and_extension
(
extensions
=
[
format
,
extension
].
compact
.
join
(
"."
)).
blank?
?
nil
:
extensions
end
memo
r
ize
:format_and_extension
memoize
:format_and_extension
def
path
[
base_path
,
[
name
,
format
,
extension
].
compact
.
join
(
'.'
)].
compact
.
join
(
'/'
)
end
memo
r
ize
:path
memoize
:path
def
path_without_extension
[
base_path
,
[
name
,
format
].
compact
.
join
(
'.'
)].
compact
.
join
(
'/'
)
end
memo
r
ize
:path_without_extension
memoize
:path_without_extension
def
path_without_format_and_extension
[
base_path
,
name
].
compact
.
join
(
'/'
)
end
memo
r
ize
:path_without_format_and_extension
memoize
:path_without_format_and_extension
def
source
File
.
read
(
filename
)
end
memo
r
ize
:source
memoize
:source
def
method_segment
segment
=
File
.
expand_path
(
filename
)
segment
.
sub!
(
/^
#{
Regexp
.
escape
(
File
.
expand_path
(
RAILS_ROOT
))
}
/
,
''
)
if
defined?
(
RAILS_ROOT
)
segment
.
gsub!
(
/([^a-zA-Z0-9_])/
)
{
$1
.
ord
}
end
memo
r
ize
:method_segment
memoize
:method_segment
def
render_template
(
view
,
local_assigns
=
{})
render
(
view
,
local_assigns
)
...
...
activesupport/lib/active_support/memoizable.rb
浏览文件 @
001c8beb
...
...
@@ -5,8 +5,8 @@ def self.included(base) #:nodoc:
end
module
ClassMethods
def
memo
r
ize
(
symbol
)
original_method
=
"_unmemo
r
ized_
#{
symbol
}
"
def
memoize
(
symbol
)
original_method
=
"_unmemoized_
#{
symbol
}
"
alias_method
original_method
,
symbol
class_eval
<<-
EOS
,
__FILE__
,
__LINE__
def
#{
symbol
}
...
...
@@ -22,7 +22,7 @@ def #{symbol}
def
freeze
methods
.
each
do
|
method
|
if
m
=
method
.
to_s
.
match
(
/^_unmemo
r
ized_(.*)/
)
if
m
=
method
.
to_s
.
match
(
/^_unmemoized_(.*)/
)
send
(
m
[
1
]).
freeze
end
end
...
...
activesupport/test/memoizable_test.rb
浏览文件 @
001c8beb
...
...
@@ -8,12 +8,12 @@ class Person
def
name
fetch_name_from_floppy
end
memo
r
ize
:name
memoize
:name
def
age
nil
end
memo
r
ize
:age
memoize
:age
private
def
fetch_name_from_floppy
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录