Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
88ba0560
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,发现更多精彩内容 >>
提交
88ba0560
编写于
12月 25, 2009
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor multiple parts logic and move Utils to PartContainer.
上级
ee70d1b6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
31 deletion
+24
-31
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+3
-11
actionmailer/lib/action_mailer/part.rb
actionmailer/lib/action_mailer/part.rb
+3
-11
actionmailer/lib/action_mailer/part_container.rb
actionmailer/lib/action_mailer/part_container.rb
+18
-2
actionmailer/lib/action_mailer/utils.rb
actionmailer/lib/action_mailer/utils.rb
+0
-7
未找到文件。
actionmailer/lib/action_mailer/base.rb
浏览文件 @
88ba0560
...
...
@@ -253,7 +253,7 @@ module ActionMailer #:nodoc:
# and appear last in the mime encoded message. You can also pick a different order from inside a method with
# +implicit_parts_order+.
class
Base
<
AbstractController
::
Base
include
PartContainer
,
Quoting
,
Utils
include
PartContainer
,
Quoting
extend
AdvAttrAccessor
include
AbstractController
::
Rendering
...
...
@@ -454,7 +454,7 @@ def process(method_name, *args) #:nodoc:
:default
=>
method_name
.
humanize
)
# Build the mail object itself
@mail
=
create_mail
create_mail
end
# Delivers a TMail::Mail object. By default, it delivers the cached mail
...
...
@@ -582,15 +582,7 @@ def create_mail
m
.
set_content_type
(
real_content_type
,
nil
,
ctype_attrs
)
m
.
body
=
normalize_new_lines
(
@parts
.
first
.
body
)
else
@parts
.
each
do
|
p
|
part
=
(
TMail
::
Mail
===
p
?
p
:
p
.
to_mail
(
self
))
m
.
parts
<<
part
end
if
real_content_type
=~
/multipart/
ctype_attrs
.
delete
"charset"
m
.
set_content_type
(
real_content_type
,
nil
,
ctype_attrs
)
end
setup_multiple_parts
(
m
,
real_content_type
,
ctype_attrs
)
end
@mail
=
m
...
...
actionmailer/lib/action_mailer/part.rb
浏览文件 @
88ba0560
...
...
@@ -4,7 +4,7 @@ module ActionMailer
# and add them to the +parts+ list of the mailer, it is easier
# to use the helper methods in ActionMailer::PartContainer.
class
Part
include
PartContainer
,
Utils
include
PartContainer
extend
AdvAttrAccessor
# Represents the body of the part, as a string. This should not be a
...
...
@@ -83,16 +83,8 @@ def to_mail(defaults)
@parts
.
unshift
Part
.
new
(
:charset
=>
charset
,
:body
=>
@body
,
:content_type
=>
'text/plain'
)
@body
=
nil
end
@parts
.
each
do
|
p
|
prt
=
(
TMail
::
Mail
===
p
?
p
:
p
.
to_mail
(
defaults
))
part
.
parts
<<
prt
end
if
real_content_type
=~
/multipart/
ctype_attrs
.
delete
'charset'
part
.
set_content_type
(
real_content_type
,
nil
,
ctype_attrs
)
end
setup_multiple_parts
(
part
,
real_content_type
,
ctype_attrs
)
end
headers
.
each
{
|
k
,
v
|
part
[
k
]
=
v
}
...
...
actionmailer/lib/action_mailer/part_container.rb
浏览文件 @
88ba0560
...
...
@@ -39,8 +39,24 @@ def attachment(params, &block)
end
private
def
parse_content_type
(
defaults
=
nil
)
def
normalize_new_lines
(
text
)
#:nodoc:
text
.
to_s
.
gsub
(
/\r\n?/
,
"
\n
"
)
end
def
setup_multiple_parts
(
mailer
,
real_content_type
,
ctype_attrs
)
#:nodoc:
@parts
.
each
do
|
p
|
part
=
(
TMail
::
Mail
===
p
?
p
:
p
.
to_mail
(
self
))
mailer
.
parts
<<
part
end
if
real_content_type
=~
/multipart/
ctype_attrs
.
delete
"charset"
mailer
.
set_content_type
(
real_content_type
,
nil
,
ctype_attrs
)
end
end
def
parse_content_type
(
defaults
=
nil
)
#:nodoc:
if
content_type
.
blank?
return
defaults
?
[
defaults
.
content_type
,
{
'charset'
=>
defaults
.
charset
}
]
:
...
...
actionmailer/lib/action_mailer/utils.rb
已删除
100644 → 0
浏览文件 @
ee70d1b6
module
ActionMailer
module
Utils
#:nodoc:
def
normalize_new_lines
(
text
)
text
.
to_s
.
gsub
(
/\r\n?/
,
"
\n
"
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录