mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
update ActionMailer documentation [ci skip]
This commit is contained in:
parent
e9acafd984
commit
e2c7545cdd
5 changed files with 15 additions and 18 deletions
|
@ -2,7 +2,7 @@ require 'abstract_controller/collector'
|
||||||
require 'active_support/core_ext/hash/reverse_merge'
|
require 'active_support/core_ext/hash/reverse_merge'
|
||||||
require 'active_support/core_ext/array/extract_options'
|
require 'active_support/core_ext/array/extract_options'
|
||||||
|
|
||||||
module ActionMailer #:nodoc:
|
module ActionMailer
|
||||||
class Collector
|
class Collector
|
||||||
include AbstractController::Collector
|
include AbstractController::Collector
|
||||||
attr_reader :responses
|
attr_reader :responses
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
|
|
||||||
module ActionMailer
|
module ActionMailer
|
||||||
# This module handles everything related to mail delivery, from registering new
|
# This module handles everything related to mail delivery, from registering
|
||||||
# delivery methods to configuring the mail object to be sent.
|
# new delivery methods to configuring the mail object to be sent.
|
||||||
module DeliveryMethods
|
module DeliveryMethods
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
@ -42,22 +42,19 @@ module ActionMailer
|
||||||
# Provides a list of emails that have been delivered by Mail::TestMailer
|
# Provides a list of emails that have been delivered by Mail::TestMailer
|
||||||
delegate :deliveries, :deliveries=, :to => Mail::TestMailer
|
delegate :deliveries, :deliveries=, :to => Mail::TestMailer
|
||||||
|
|
||||||
# Adds a new delivery method through the given class using the given symbol
|
# Adds a new delivery method through the given class using the given
|
||||||
# as alias and the default options supplied:
|
# symbol as alias and the default options supplied.
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
#
|
#
|
||||||
# add_delivery_method :sendmail, Mail::Sendmail,
|
# add_delivery_method :sendmail, Mail::Sendmail,
|
||||||
# :location => '/usr/sbin/sendmail',
|
# location: '/usr/sbin/sendmail',
|
||||||
# :arguments => '-i -t'
|
# arguments: '-i -t'
|
||||||
#
|
|
||||||
def add_delivery_method(symbol, klass, default_options={})
|
def add_delivery_method(symbol, klass, default_options={})
|
||||||
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
|
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
|
||||||
send(:"#{symbol}_settings=", default_options)
|
send(:"#{symbol}_settings=", default_options)
|
||||||
self.delivery_methods = delivery_methods.merge(symbol.to_sym => klass).freeze
|
self.delivery_methods = delivery_methods.merge(symbol.to_sym => klass).freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrap_delivery_behavior(mail, method=nil, options=nil) #:nodoc:
|
def wrap_delivery_behavior(mail, method=nil, options=nil) # :nodoc:
|
||||||
method ||= self.delivery_method
|
method ||= self.delivery_method
|
||||||
mail.delivery_handler = self
|
mail.delivery_handler = self
|
||||||
|
|
||||||
|
@ -79,7 +76,7 @@ module ActionMailer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrap_delivery_behavior!(*args) #:nodoc:
|
def wrap_delivery_behavior!(*args) # :nodoc:
|
||||||
self.class.wrap_delivery_behavior(message, *args)
|
self.class.wrap_delivery_behavior(message, *args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module ActionMailer
|
module ActionMailer
|
||||||
module MailHelper
|
module MailHelper
|
||||||
# Take the text and format it, indented two spaces for each line, and wrapped at 72 columns.
|
# Take the text and format it, indented two spaces for each line, and
|
||||||
|
# wrapped at 72 columns.
|
||||||
def block_format(text)
|
def block_format(text)
|
||||||
formatted = text.split(/\n\r?\n/).collect { |paragraph|
|
formatted = text.split(/\n\r?\n/).collect { |paragraph|
|
||||||
format_paragraph(paragraph)
|
format_paragraph(paragraph)
|
||||||
|
@ -30,9 +31,7 @@ module ActionMailer
|
||||||
|
|
||||||
# Returns +text+ wrapped at +len+ columns and indented +indent+ spaces.
|
# Returns +text+ wrapped at +len+ columns and indented +indent+ spaces.
|
||||||
#
|
#
|
||||||
# === Examples
|
# my_text = 'Here is a sample text with more than 40 characters'
|
||||||
#
|
|
||||||
# my_text = "Here is a sample text with more than 40 characters"
|
|
||||||
#
|
#
|
||||||
# format_paragraph(my_text, 25, 4)
|
# format_paragraph(my_text, 25, 4)
|
||||||
# # => " Here is a sample text with\n more than 40 characters"
|
# # => " Here is a sample text with\n more than 40 characters"
|
||||||
|
|
|
@ -3,7 +3,7 @@ require "rails"
|
||||||
require "abstract_controller/railties/routes_helpers"
|
require "abstract_controller/railties/routes_helpers"
|
||||||
|
|
||||||
module ActionMailer
|
module ActionMailer
|
||||||
class Railtie < Rails::Railtie
|
class Railtie < Rails::Railtie # :nodoc:
|
||||||
config.action_mailer = ActiveSupport::OrderedOptions.new
|
config.action_mailer = ActiveSupport::OrderedOptions.new
|
||||||
config.eager_load_namespaces << ActionMailer
|
config.eager_load_namespaces << ActionMailer
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@ module ActionMailer
|
||||||
# assert_emails 2
|
# assert_emails 2
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# If a block is passed, that block should cause the specified number of emails to be sent.
|
# If a block is passed, that block should cause the specified number of
|
||||||
|
# emails to be sent.
|
||||||
#
|
#
|
||||||
# def test_emails_again
|
# def test_emails_again
|
||||||
# assert_emails 1 do
|
# assert_emails 1 do
|
||||||
|
|
Loading…
Reference in a new issue