Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
b5f9a9fc
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,发现更多精彩内容 >>
提交
b5f9a9fc
编写于
4月 12, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move set_fields! to the old API module.
上级
e5f392ce
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
28 addition
and
28 deletion
+28
-28
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+16
-27
actionmailer/lib/action_mailer/old_api.rb
actionmailer/lib/action_mailer/old_api.rb
+12
-1
未找到文件。
actionmailer/lib/action_mailer/base.rb
浏览文件 @
b5f9a9fc
...
...
@@ -525,19 +525,25 @@ def mail(headers={}, &block)
content_type
=
headers
[
:content_type
]
parts_order
=
headers
[
:parts_order
]
#
Merge defaults from clas
s
#
Handle default
s
headers
=
headers
.
reverse_merge
(
self
.
class
.
default
)
charset
=
headers
.
delete
(
:charset
)
# Quote fields
headers
[
:subject
]
||=
default_i18n_subject
set_fields!
(
headers
,
charset
)
# Apply charset at the beginning so all fields are properly quoted
m
.
charset
=
charset
=
headers
[
:charset
]
# Set configure delivery behavior
wrap_delivery_behavior!
(
headers
.
delete
(
:delivery_method
))
# Assign all headers except parts_order, content_type and body
assignable
=
headers
.
except
(
:parts_order
,
:content_type
,
:body
)
assignable
.
each
{
|
k
,
v
|
m
[
k
]
=
v
}
# Render the templates and blocks
responses
,
explicit_order
=
collect_responses_and_parts_order
(
headers
,
&
block
)
create_parts_from_responses
(
m
,
responses
,
charset
)
create_parts_from_responses
(
m
,
responses
)
#
Finally setup content type and
parts order
#
Setup content type, reapply charset and handle
parts order
m
.
content_type
=
set_content_type
(
m
,
content_type
,
headers
[
:content_type
])
m
.
charset
=
charset
...
...
@@ -547,12 +553,6 @@ def mail(headers={}, &block)
m
.
body
.
sort_parts!
end
# Set configure delivery behavior
wrap_delivery_behavior!
(
headers
.
delete
(
:delivery_method
))
# Remove any missing configuration header and assign all others
headers
.
except!
(
:parts_order
,
:content_type
)
headers
.
each
{
|
k
,
v
|
m
[
k
]
=
v
}
m
end
...
...
@@ -577,17 +577,6 @@ def default_i18n_subject #:nodoc:
I18n
.
t
(
:subject
,
:scope
=>
[
:actionmailer
,
mailer_scope
,
action_name
],
:default
=>
action_name
.
humanize
)
end
def
set_fields!
(
headers
,
charset
)
#:nodoc:
m
=
@_message
m
.
charset
=
charset
m
.
subject
||=
headers
.
delete
(
:subject
)
if
headers
[
:subject
]
m
.
to
||=
headers
.
delete
(
:to
)
if
headers
[
:to
]
m
.
from
||=
headers
.
delete
(
:from
)
if
headers
[
:from
]
m
.
cc
||=
headers
.
delete
(
:cc
)
if
headers
[
:cc
]
m
.
bcc
||=
headers
.
delete
(
:bcc
)
if
headers
[
:bcc
]
m
.
reply_to
||=
headers
.
delete
(
:reply_to
)
if
headers
[
:reply_to
]
end
def
collect_responses_and_parts_order
(
headers
)
#:nodoc:
responses
,
parts_order
=
[],
nil
...
...
@@ -630,16 +619,16 @@ def each_template(paths, name, &block) #:nodoc:
end
end
def
create_parts_from_responses
(
m
,
responses
,
charset
)
#:nodoc:
def
create_parts_from_responses
(
m
,
responses
)
#:nodoc:
if
responses
.
size
==
1
&&
!
m
.
has_attachments?
responses
[
0
].
each
{
|
k
,
v
|
m
[
k
]
=
v
}
elsif
responses
.
size
>
1
&&
m
.
has_attachments?
container
=
Mail
::
Part
.
new
container
.
content_type
=
"multipart/alternative"
responses
.
each
{
|
r
|
insert_part
(
container
,
r
,
charset
)
}
responses
.
each
{
|
r
|
insert_part
(
container
,
r
,
m
.
charset
)
}
m
.
add_part
(
container
)
else
responses
.
each
{
|
r
|
insert_part
(
m
,
r
,
charset
)
}
responses
.
each
{
|
r
|
insert_part
(
m
,
r
,
m
.
charset
)
}
end
end
...
...
actionmailer/lib/action_mailer/old_api.rb
浏览文件 @
b5f9a9fc
...
...
@@ -230,6 +230,17 @@ def create_inline_part(body, mime_type=nil)
)
end
def
set_fields!
(
headers
,
charset
)
#:nodoc:
m
=
@_message
m
.
charset
=
charset
m
.
subject
||=
headers
.
delete
(
:subject
)
if
headers
[
:subject
]
m
.
to
||=
headers
.
delete
(
:to
)
if
headers
[
:to
]
m
.
from
||=
headers
.
delete
(
:from
)
if
headers
[
:from
]
m
.
cc
||=
headers
.
delete
(
:cc
)
if
headers
[
:cc
]
m
.
bcc
||=
headers
.
delete
(
:bcc
)
if
headers
[
:bcc
]
m
.
reply_to
||=
headers
.
delete
(
:reply_to
)
if
headers
[
:reply_to
]
end
def
split_content_type
(
ct
)
ct
.
to_s
.
split
(
"/"
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录