Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
b6ccaee9
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,体验更适合开发者的 AI 搜索 >>
提交
b6ccaee9
编写于
8月 21, 2014
作者:
X
Xavier Noria
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
applies API guidelines to new AM docs
上级
b55e7e3f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
32 deletion
+32
-32
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+5
-5
actionmailer/lib/action_mailer/message_delivery.rb
actionmailer/lib/action_mailer/message_delivery.rb
+27
-27
未找到文件。
actionmailer/lib/action_mailer/base.rb
浏览文件 @
b6ccaee9
...
...
@@ -139,19 +139,19 @@ module ActionMailer
# for delivery later:
#
# Notifier.welcome(User.first).deliver_now # sends the email
# mail = Notifier.welcome(User.first) # => an ActionMailer::MessageDeliver object
# mail = Notifier.welcome(User.first) # => an ActionMailer::MessageDeliver
y
object
# mail.deliver_now # sends the email
#
# The <tt>ActionMailer::MessageDeliver</tt> class is a wrapper around a <tt>Mail::Message</tt> object. If
# The <tt>ActionMailer::MessageDeliver
y
</tt> class is a wrapper around a <tt>Mail::Message</tt> object. If
# you want direct access to the <tt>Mail::Message</tt> object you can call the <tt>message</tt> method on
# the <tt>ActionMailer::MessageDeliver</tt> object.
# the <tt>ActionMailer::MessageDeliver
y
</tt> object.
#
# Notifier.welcome(User.first).message # => a Mail::Message object
#
# Action
Mailer is nicely integrated with Active
Job so you can send emails in the background (example: outside
# Action
Mailer is nicely integrated with Active
Job so you can send emails in the background (example: outside
# of the request-response cycle, so the user doesn't have to wait on it):
#
# Notifier.welcome(User.first).deliver_later # enqueue the email sending to ActiveJob
# Notifier.welcome(User.first).deliver_later # enqueue the email sending to Active
Job
#
# You never instantiate your mailer class. Rather, you just call the method you defined on the class itself.
#
...
...
actionmailer/lib/action_mailer/message_delivery.rb
浏览文件 @
b6ccaee9
...
...
@@ -2,14 +2,16 @@
module
ActionMailer
# The ActionMailer::MessageDeliver class is used by ActionMailer::Base when
# creating a new mailer. MessageDeliver is a wrapper (Delegator subclass)
# around a lazy created Mail::Message. You can get direct access to the
# Mail::Message, deliver the email or schedule the email to be sent through ActiveJob.
# The <tt>ActionMailer::MessageDelivery</tt> class is used by
# <tt>ActionMailer::Base</tt> when creating a new mailer.
# <tt>MessageDelivery</tt> is a wrapper (+Delegator+ subclass) around a lazy
# created <tt>Mail::Message</tt>. You can get direct access to the
# <tt>Mail::Message</tt>, deliver the email or schedule the email to be sent
# through Active Job.
#
# Notifier.welcome(User.first) # an ActionMailer::MessageDeliver object
# Notifier.welcome(User.first) # an ActionMailer::MessageDeliver
y
object
# Notifier.welcome(User.first).deliver_now # sends the email
# Notifier.welcome(User.first).deliver_later # enqueue
the deliver email job to Active
Job
# Notifier.welcome(User.first).deliver_later # enqueue
email delivery as a job through Active
Job
# Notifier.welcome(User.first).message # a Mail::Message object
class
MessageDelivery
<
Delegator
def
initialize
(
mailer
,
mail_method
,
*
args
)
#:nodoc:
...
...
@@ -31,42 +33,40 @@ def message
__getobj__
end
# Enqueues the message to be delivered through ActiveJob. When the
# ActiveJob job runs it will send the email using #deliver_now!. That
# means that the message will be sent bypassing checking perform_deliveries
# and raise_delivery_errors, so use with caution.
#
# ==== Examples
# Enqueues the email to be delivered through Active Job. When the
# job runs it will send the email using +deliver_now!+. That means
# that the message will be sent bypassing checking +perform_deliveries+
# and +raise_delivery_errors+, so use with caution.
#
# Notifier.welcome(User.first).deliver_later
# Notifier.welcome(User.first).deliver_later(in: 1.hour)
# Notifier.welcome(User.first).deliver_later(at: 10.hours.from_now)
#
# ==== Options
# * <tt>in</tt> - Enqueue the message to be delivered with a delay
# * <tt>at</tt> - Enqueue the message to be delivered at (after) a specific date / time
# Options:
#
# * <tt>:in</tt> - Enqueue the email to be delivered with a delay
# * <tt>:at</tt> - Enqueue the email to be delivered at (after) a specific date / time
def
deliver_later!
(
options
=
{})
enqueue_delivery
:deliver_now!
,
options
end
# Enqueues the message to be delivered through ActiveJob. When the
# ActiveJob job runs it will send the email using #deliver_now.
#
# ==== Examples
# Enqueues the email to be delivered through Active Job. When the
# job runs it will send the email using +deliver_now+.
#
# Notifier.welcome(User.first).deliver_later
# Notifier.welcome(User.first).deliver_later(in: 1.hour)
# Notifier.welcome(User.first).deliver_later(at: 10.hours.from_now)
#
# ==== Options
# * <tt>in</tt> - Enqueue the message to be delivered with a delay
# * <tt>at</tt> - Enqueue the message to be delivered at (after) a specific date / time
# Options:
#
# * <tt>:in</tt> - Enqueue the email to be delivered with a delay
# * <tt>:at</tt> - Enqueue the email to be delivered at (after) a specific date / time
def
deliver_later
(
options
=
{})
enqueue_delivery
:deliver_now
,
options
end
# Delivers a
message. The message will be sent bypassing checking perform_deliveries
#
and raise_delivery_errors,
so use with caution.
# Delivers a
n email without checking +perform_deliveries+ and +raise_delivery_errors+,
# so use with caution.
#
# Notifier.welcome(User.first).deliver_now!
#
...
...
@@ -74,7 +74,7 @@ def deliver_now!
message
.
deliver!
end
# Delivers a
message
:
# Delivers a
n email
:
#
# Notifier.welcome(User.first).deliver_now
#
...
...
@@ -84,13 +84,13 @@ def deliver_now
def
deliver!
#:nodoc:
ActiveSupport
::
Deprecation
.
warn
"#deliver! is deprecated and will be removed in Rails 5. "
\
"Use #deliver_now! to deliver immediately or #deliver_later! to deliver through ActiveJob."
"Use #deliver_now! to deliver immediately or #deliver_later! to deliver through Active
Job."
deliver_now!
end
def
deliver
#:nodoc:
ActiveSupport
::
Deprecation
.
warn
"#deliver is deprecated and will be removed in Rails 5. "
\
"Use #deliver_now to deliver immediately or #deliver_later to deliver through ActiveJob."
"Use #deliver_now to deliver immediately or #deliver_later to deliver through Active
Job."
deliver_now
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录