diff options
Diffstat (limited to 'actionmailer/lib')
-rw-r--r-- | actionmailer/lib/action_mailer.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 12 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/inline_preview_interceptor.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/message_delivery.rb | 24 |
4 files changed, 25 insertions, 15 deletions
diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index ade3fe39a2..fabbdd1b25 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true #-- -# Copyright (c) 2004-2017 David Heinemeier Hansson +# Copyright (c) 2004-2018 David Heinemeier Hansson # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index eb8ae59533..3af95081ee 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -889,7 +889,7 @@ module ActionMailer default_values = self.class.default.map do |key, value| [ key, - value.is_a?(Proc) ? instance_exec(&value) : value + compute_default(value) ] end.to_h @@ -898,6 +898,16 @@ module ActionMailer headers_with_defaults end + def compute_default(value) + return value unless value.is_a?(Proc) + + if value.arity == 1 + instance_exec(self, &value) + else + instance_exec(&value) + end + end + def assign_headers_to_message(message, headers) assignable = headers.except(:parts_order, :content_type, :body, :template_name, :template_path, :delivery_method, :delivery_method_options) diff --git a/actionmailer/lib/action_mailer/inline_preview_interceptor.rb b/actionmailer/lib/action_mailer/inline_preview_interceptor.rb index 4bef4a58d3..8a12f805cc 100644 --- a/actionmailer/lib/action_mailer/inline_preview_interceptor.rb +++ b/actionmailer/lib/action_mailer/inline_preview_interceptor.rb @@ -4,7 +4,7 @@ require "base64" module ActionMailer # Implements a mailer preview interceptor that converts image tag src attributes - # that use inline cid: style urls to data: style urls so that they are visible + # that use inline cid: style URLs to data: style URLs so that they are visible # when previewing an HTML email in a web browser. # # This interceptor is enabled by default. To disable it, delete it from the diff --git a/actionmailer/lib/action_mailer/message_delivery.rb b/actionmailer/lib/action_mailer/message_delivery.rb index a2ea45dc7b..2377aeb9a5 100644 --- a/actionmailer/lib/action_mailer/message_delivery.rb +++ b/actionmailer/lib/action_mailer/message_delivery.rb @@ -53,6 +53,12 @@ module ActionMailer # Notifier.welcome(User.first).deliver_later!(wait: 1.hour) # Notifier.welcome(User.first).deliver_later!(wait_until: 10.hours.from_now) # + # Options: + # + # * <tt>:wait</tt> - Enqueue the email to be delivered with a delay + # * <tt>:wait_until</tt> - Enqueue the email to be delivered at (after) a specific date / time + # * <tt>:queue</tt> - Enqueue the email on the specified queue + # # By default, the email will be enqueued using <tt>ActionMailer::DeliveryJob</tt>. Each # <tt>ActionMailer::Base</tt> class can specify the job to use by setting the class variable # +delivery_job+. @@ -60,12 +66,6 @@ module ActionMailer # class AccountRegistrationMailer < ApplicationMailer # self.delivery_job = RegistrationDeliveryJob # end - # - # Options: - # - # * <tt>:wait</tt> - Enqueue the email to be delivered with a delay - # * <tt>:wait_until</tt> - Enqueue the email to be delivered at (after) a specific date / time - # * <tt>:queue</tt> - Enqueue the email on the specified queue def deliver_later!(options = {}) enqueue_delivery :deliver_now!, options end @@ -77,6 +77,12 @@ module ActionMailer # Notifier.welcome(User.first).deliver_later(wait: 1.hour) # Notifier.welcome(User.first).deliver_later(wait_until: 10.hours.from_now) # + # Options: + # + # * <tt>:wait</tt> - Enqueue the email to be delivered with a delay. + # * <tt>:wait_until</tt> - Enqueue the email to be delivered at (after) a specific date / time. + # * <tt>:queue</tt> - Enqueue the email on the specified queue. + # # By default, the email will be enqueued using <tt>ActionMailer::DeliveryJob</tt>. Each # <tt>ActionMailer::Base</tt> class can specify the job to use by setting the class variable # +delivery_job+. @@ -84,12 +90,6 @@ module ActionMailer # class AccountRegistrationMailer < ApplicationMailer # self.delivery_job = RegistrationDeliveryJob # end - # - # Options: - # - # * <tt>:wait</tt> - Enqueue the email to be delivered with a delay. - # * <tt>:wait_until</tt> - Enqueue the email to be delivered at (after) a specific date / time. - # * <tt>:queue</tt> - Enqueue the email on the specified queue. def deliver_later(options = {}) enqueue_delivery :deliver_now, options end |