Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
32baa278
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,发现更多精彩内容 >>
提交
32baa278
编写于
8月 02, 2010
作者:
P
Piotr Sarnacki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Include routes helpers only for inherited classes in ActionMailer
上级
befa77fc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
67 addition
and
27 deletion
+67
-27
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+9
-21
actionmailer/lib/action_mailer/hide_actions.rb
actionmailer/lib/action_mailer/hide_actions.rb
+46
-0
actionmailer/lib/action_mailer/railtie.rb
actionmailer/lib/action_mailer/railtie.rb
+1
-2
actionmailer/lib/action_mailer/railties/routes_helpers.rb
actionmailer/lib/action_mailer/railties/routes_helpers.rb
+10
-4
railties/test/railties/engine_test.rb
railties/test/railties/engine_test.rb
+1
-0
未找到文件。
actionmailer/lib/action_mailer/base.rb
浏览文件 @
32baa278
...
...
@@ -5,6 +5,7 @@
require
'active_support/core_ext/object/blank'
require
'active_support/core_ext/proc'
require
'action_mailer/log_subscriber'
require
'action_mailer/hide_actions'
module
ActionMailer
#:nodoc:
# Action Mailer allows you to send email from your application using a mailer model and views.
...
...
@@ -346,6 +347,7 @@ class Base < AbstractController::Base
helper
ActionMailer
::
MailHelper
include
ActionMailer
::
OldApi
include
ActionMailer
::
HideActions
delegate
:register_observer
,
:to
=>
Mail
delegate
:register_interceptor
,
:to
=>
Mail
...
...
@@ -361,6 +363,11 @@ class Base < AbstractController::Base
}.
freeze
class
<<
self
def
inherited
(
klass
)
klass
.
with_hiding_actions
do
super
(
klass
)
end
end
def
mailer_name
@mailer_name
||=
name
.
underscore
...
...
@@ -725,27 +732,8 @@ def insert_part(container, response, charset) #:nodoc:
container
.
add_part
(
part
)
end
module
DeprecatedUrlOptions
def
default_url_options
deprecated_url_options
end
def
default_url_options
=
(
val
)
deprecated_url_options
end
def
deprecated_url_options
raise
"You can no longer call ActionMailer::Base.default_url_options "
\
"directly. You need to set config.action_mailer.default_url_options. "
\
"If you are using ActionMailer standalone, you need to include the "
\
"routing url_helpers directly."
end
end
# This module will complain if the user tries to set default_url_options
# directly instead of through the config object. In Action Mailer's Railtie,
# we include the router's url_helpers, which will override this module.
extend
DeprecatedUrlOptions
class_attribute
:default_url_options
self
.
default_url_options
=
{}
ActiveSupport
.
run_load_hooks
(
:action_mailer
,
self
)
end
...
...
actionmailer/lib/action_mailer/hide_actions.rb
0 → 100644
浏览文件 @
32baa278
require
'active_support/core_ext/class/attribute'
module
ActionMailer
# ActionController::HideActions adds the ability to prevent public methods on a controller
# to be called as actions.
module
HideActions
extend
ActiveSupport
::
Concern
included
do
class_attribute
:hidden_actions
self
.
hidden_actions
=
Set
.
new
.
freeze
end
private
module
ClassMethods
# Sets all of the actions passed in as hidden actions.
#
# ==== Parameters
# *args<#to_s>:: A list of actions
def
hide_action
(
*
args
)
self
.
hidden_actions
=
hidden_actions
.
dup
.
merge
(
args
.
map
(
&
:to_s
)).
freeze
end
# Run block and add all the new action_methods to hidden_actions.
# This is used in inherited method.
def
with_hiding_actions
yield
clear_action_methods!
hide_action
(
*
action_methods
)
clear_action_methods!
end
def
clear_action_methods!
@action_methods
=
nil
end
# Overrides AbstractController::Base#action_methods to remove any methods
# that are listed as hidden methods.
def
action_methods
@action_methods
||=
super
.
reject
{
|
name
|
hidden_actions
.
include?
(
name
)
}
end
end
end
end
actionmailer/lib/action_mailer/railtie.rb
浏览文件 @
32baa278
...
...
@@ -19,9 +19,8 @@ class Railtie < Rails::Railtie
options
.
stylesheets_dir
||=
paths
.
public
.
stylesheets
.
to_a
.
first
ActiveSupport
.
on_load
(
:action_mailer
)
do
include
app
.
routes
.
url_helpers
extend
::
ActionMailer
::
Railties
::
RoutesHelpers
.
with
(
app
.
routes
)
include
app
.
routes
.
mounted_helpers
(
:app
)
extend
::
ActionMailer
::
Railties
::
RoutesHelpers
options
.
each
{
|
k
,
v
|
send
(
"
#{
k
}
="
,
v
)
}
end
end
...
...
actionmailer/lib/action_mailer/railties/routes_helpers.rb
浏览文件 @
32baa278
module
ActionMailer
module
Railties
module
RoutesHelpers
def
inherited
(
klass
)
super
(
klass
)
if
namespace
=
klass
.
parents
.
detect
{
|
m
|
m
.
respond_to?
(
:_railtie
)
}
klass
.
send
(
:include
,
namespace
.
_railtie
.
routes
.
url_helpers
)
def
self
.
with
(
routes
)
Module
.
new
do
define_method
(
:inherited
)
do
|
klass
|
super
(
klass
)
if
namespace
=
klass
.
parents
.
detect
{
|
m
|
m
.
respond_to?
(
:_railtie
)
}
klass
.
send
(
:include
,
namespace
.
_railtie
.
routes
.
url_helpers
)
else
klass
.
send
(
:include
,
routes
.
url_helpers
)
end
end
end
end
end
...
...
railties/test/railties/engine_test.rb
浏览文件 @
32baa278
...
...
@@ -410,6 +410,7 @@ class MyMailer < ActionMailer::Base
assert_equal
Bukkits
.
_railtie
,
Bukkits
::
Engine
assert
::
Bukkits
::
MyMailer
.
method_defined?
(
:foo_path
)
assert
!::
Bukkits
::
MyMailer
.
method_defined?
(
:bar_path
)
env
=
Rack
::
MockRequest
.
env_for
(
"/bukkits/from_app"
)
response
=
AppTemplate
::
Application
.
call
(
env
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录