Tuned documentation for release (AM)

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1726 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 8dbaae60
*SVN*
*1.0.0* (6 July, 2005)
* Avoid adding nil header values #1392
......
......@@ -16,16 +16,15 @@ in methods on the service layer. Subject, recipients, sender, and timestamp
are all set up this way. An example of such a method:
def signed_up(recipient)
@recipients = recipient
@subject = "[Signed up] Welcome #{recipient}"
@from = "system@loudthinking.com"
@sent_on = Time.local(2004, 12, 12)
recipients recipient
subject "[Signed up] Welcome #{recipient}"
from "system@loudthinking.com"
@body["recipient"] = recipient
body(:recipient => recipient)
end
The body of the email is created by using an Action View template (regular
ERb) that has the content of the @body hash available as instance variables.
ERb) that has the content of the body hash parameter available as instance variables.
So the corresponding body template for the method above could look like this:
Hello there,
......
module ActionMailer
module AdvAttrAccessor
module AdvAttrAccessor #:nodoc:
def self.append_features(base)
super
base.extend(ClassMethods)
end
module ClassMethods
module ClassMethods #:nodoc:
def adv_attr_accessor(*names)
names.each do |name|
define_method("#{name}=") do |value|
......@@ -23,19 +22,18 @@ def adv_attr_accessor(*names)
end
end
end
end
end
end
module ActionMailer
module AdvAttrAccessor
module AdvAttrAccessor #:nodoc:
def self.append_features(base)
super
base.extend(ClassMethods)
end
module ClassMethods
module ClassMethods #:nodoc:
def adv_attr_accessor(*names)
names.each do |name|
define_method("#{name}=") do |value|
......
......@@ -13,7 +13,7 @@ module ActionMailer #:nodoc:
# def signup_notification(recipient)
# recipients recipient.email_address_with_name
# subject "New account information"
# body Hash.new("account" => recipient)
# body { "account" => recipient }
# from "system@example.com"
# end
#
......@@ -164,13 +164,13 @@ class Base
# will be initialized according to the named method. If not, the mailer will
# remain uninitialized (useful when you only need to invoke the "receive"
# method, for instance).
def initialize(method_name=nil, *parameters)
def initialize(method_name=nil, *parameters) #:nodoc:
create!(method_name, *parameters) if method_name
end
# Initialize the mailer via the given +method_name+. The body will be
# rendered and a new TMail::Mail object created.
def create!(method_name, *parameters)
def create!(method_name, *parameters) #:nodoc:
@bcc = @cc = @from = @recipients = @sent_on = @subject = nil
@charset = @@default_charset.dup
@content_type = @@default_content_type.dup
......@@ -225,7 +225,7 @@ def create!(method_name, *parameters)
# Delivers the cached TMail::Mail object. If no TMail::Mail object has been
# created (via the #create! method, for instance) this will fail.
def deliver!
def deliver! #:nodoc:
raise "no mail object available for delivery!" unless @mail
logger.info "Sent mail:\n #{mail.encoded}" unless logger.nil?
......
......@@ -24,28 +24,7 @@ class << self
end
end
# The template helpers serves to relieve the templates from including the same inline code again and again. It's a
# set of standardized methods for working with forms (FormHelper), dates (DateHelper), texts (TextHelper), and
# Active Records (ActiveRecordHelper) that's available to all templates by default.
#
# It's also really easy to make your own helpers and it's much encouraged to keep the template files free
# from complicated logic. It's even encouraged to bundle common compositions of methods from other helpers
# (often the common helpers) as they're used by the specific application.
#
# module MyHelper
# def hello_world() "hello world" end
# end
#
# MyHelper can now be included in a controller, like this:
#
# class MyController < ActionController::Base
# helper :my_helper
# end
#
# ...and, same as above, used in any template rendered from MyController, like this:
#
# Let's hear what the helper has to say: <tt><%= hello_world %></tt>
module ClassMethods
module ClassMethods #:nodoc:
# Makes all the (instance) methods in the helper module available to templates rendered through this controller.
# See ActionView::Helpers (link:classes/ActionView/Helpers.html) for more about making your own helper modules
# available to the templates.
......@@ -133,4 +112,4 @@ def initialize_template_class_with_helper(assigns)
end
end
end
end
end
\ No newline at end of file
......@@ -2,7 +2,6 @@
require 'action_mailer/part_container'
module ActionMailer
class Part #:nodoc:
include ActionMailer::AdvAttrAccessor
include ActionMailer::PartContainer
......@@ -69,10 +68,8 @@ def to_mail(defaults)
end
private
def squish(values={})
values.delete_if { |k,v| v.nil? }
end
end
end
module ActionMailer
module PartContainer
module PartContainer #:nodoc:
attr_reader :parts
# Add a part to a multipart message, with the given content-type. The
......
module ActionMailer
module Quoting
module Quoting #:nodoc:
# Convert the given text into quoted printable format, with an instruction
# that the text be eventually interpreted in the given charset.
def quoted_printable(text, charset)
......@@ -45,12 +44,11 @@ def quote_address_if_necessary(address, charset)
def quote_any_address_if_necessary(charset, *args)
args.map { |v| quote_address_if_necessary(v, charset) }
end
end
end
module ActionMailer
module Quoting
module ActionMailer
module Quoting #:nodoc:
# Convert the given text into quoted printable format, with an instruction
# that the text be eventually interpreted in the given charset.
def quoted_printable(text, charset)
......@@ -97,6 +95,5 @@ def quote_address_if_necessary(address, charset)
def quote_any_address_if_necessary(charset, *args)
args.map { |v| quote_address_if_necessary(v, charset) }
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册