diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/part.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/part.rb | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/actionmailer/lib/action_mailer/part.rb b/actionmailer/lib/action_mailer/part.rb index d4b8e3b9d9..0036d04da0 100644 --- a/actionmailer/lib/action_mailer/part.rb +++ b/actionmailer/lib/action_mailer/part.rb @@ -3,13 +3,43 @@ require 'action_mailer/part_container' require 'action_mailer/utils' module ActionMailer - class Part #:nodoc: + # Represents a subpart of an email message. It shares many similar + # attributes of ActionMailer::Base. Although you can create parts manually + # and add them to the #parts list of the mailer, it is easier + # to use the helper methods in ActionMailer::PartContainer. + class Part include ActionMailer::AdvAttrAccessor include ActionMailer::PartContainer - adv_attr_accessor :content_type, :content_disposition, :charset, :body - adv_attr_accessor :filename, :transfer_encoding, :headers + # Represents the body of the part, as a string. This should not be a + # Hash (like ActionMailer::Base), but if you want a template to be rendered + # into the body of a subpart you can do it with the mailer's #render method + # and assign the result here. + adv_attr_accessor :body + + # Specify the charset for this subpart. By default, it will be the charset + # of the containing part or mailer. + adv_attr_accessor :charset + + # The content disposition of this part, typically either "inline" or + # "attachment". + adv_attr_accessor :content_disposition + + # The content type of the part. + adv_attr_accessor :content_type + + # The filename to use for this subpart (usually for attachments). + adv_attr_accessor :filename + + # Accessor for specifying additional headers to include with this part. + adv_attr_accessor :headers + + # The transfer encoding to use for this subpart, like "base64" or + # "quoted-printable". + adv_attr_accessor :transfer_encoding + # Create a new part from the given +params+ hash. The valid params keys + # correspond to the accessors. def initialize(params) @content_type = params[:content_type] @content_disposition = params[:disposition] || "inline" @@ -21,6 +51,8 @@ module ActionMailer @parts = [] end + # Convert the part to a mail object which can be included in the parts + # list of another mail object. def to_mail(defaults) part = TMail::Mail.new |