Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
2717f004
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,发现更多精彩内容 >>
提交
2717f004
编写于
5月 26, 2013
作者:
K
kirill
提交者:
mokevnin
4月 20, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
replace class_eval by define_method in abstract_controller/callbacks
上级
86b02826
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
35 deletion
+29
-35
actionpack/lib/abstract_controller/callbacks.rb
actionpack/lib/abstract_controller/callbacks.rb
+29
-35
未找到文件。
actionpack/lib/abstract_controller/callbacks.rb
浏览文件 @
2717f004
...
...
@@ -178,41 +178,35 @@ def _insert_callbacks(callbacks, block = nil)
# set up before_action, prepend_before_action, skip_before_action, etc.
# for each of before, after, and around.
[
:before
,
:after
,
:around
].
each
do
|
callback
|
class_eval
<<-
RUBY_EVAL
,
__FILE__
,
__LINE__
+
1
# Append a before, after or around callback. See _insert_callbacks
# for details on the allowed parameters.
def
#{
callback
}
_action(*names, &blk) # def before_action(*names, &blk)
_insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options|
set_callback(:process_action, :
#{
callback
}
, name, options) # set_callback(:process_action, :before, name, options)
end # end
end # end
alias_method :
#{
callback
}
_filter, :
#{
callback
}
_action
# Prepend a before, after or around callback. See _insert_callbacks
# for details on the allowed parameters.
def prepend_
#{
callback
}
_action(*names, &blk) # def prepend_before_action(*names, &blk)
_insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options|
set_callback(:process_action, :
#{
callback
}
, name, options.merge(:prepend => true)) # set_callback(:process_action, :before, name, options.merge(:prepend => true))
end # end
end # end
alias_method :prepend_
#{
callback
}
_filter, :prepend_
#{
callback
}
_action
# Skip a before, after or around callback. See _insert_callbacks
# for details on the allowed parameters.
def skip_
#{
callback
}
_action(*names) # def skip_before_action(*names)
_insert_callbacks(names) do |name, options| # _insert_callbacks(names) do |name, options|
skip_callback(:process_action, :
#{
callback
}
, name, options) # skip_callback(:process_action, :before, name, options)
end # end
end # end
alias_method :skip_
#{
callback
}
_filter, :skip_
#{
callback
}
_action
# *_action is the same as append_*_action
alias_method :append_
#{
callback
}
_action, :
#{
callback
}
_action # alias_method :append_before_action, :before_action
alias_method :append_
#{
callback
}
_filter, :
#{
callback
}
_action # alias_method :append_before_filter, :before_action
RUBY_EVAL
define_method
"
#{
callback
}
_action"
do
|*
names
,
&
blk
|
_insert_callbacks
(
names
,
blk
)
do
|
name
,
options
|
set_callback
(
:process_action
,
callback
,
name
,
options
)
end
end
alias_method
:"
#{
callback
}
_filter"
,
:"
#{
callback
}
_action"
define_method
"prepend_
#{
callback
}
_action"
do
|*
names
,
&
blk
|
_insert_callbacks
(
names
,
blk
)
do
|
name
,
options
|
set_callback
(
:process_action
,
callback
,
name
,
options
.
merge
(
:prepend
=>
true
))
end
end
alias_method
:"prepend_
#{
callback
}
_filter"
,
:"prepend_
#{
callback
}
_action"
# Skip a before, after or around callback. See _insert_callbacks
# for details on the allowed parameters.
define_method
"skip_
#{
callback
}
_action"
do
|*
names
|
_insert_callbacks
(
names
)
do
|
name
,
options
|
skip_callback
(
:process_action
,
callback
,
name
,
options
)
end
end
alias_method
:"skip_
#{
callback
}
_filter"
,
:"skip_
#{
callback
}
_action"
# *_action is the same as append_*_action
alias_method
:"append_
#{
callback
}
_action"
,
:"
#{
callback
}
_action"
# alias_method :append_before_action, :before_action
alias_method
:"append_
#{
callback
}
_filter"
,
:"
#{
callback
}
_action"
# alias_method :append_before_filter, :before_action
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录