Attributes
| [RW] |
The mail object related to the current request. |
Public Instance methods
finish()
If the related request was an email request, add any response headers to the email, as well as adding the response body to the email. Return the email unless no body was set for it, which would indicate that the routing tree did not handle the request.
[show source]
# File lib/roda/plugins/mailer.rb 197 def finish 198 if m = mail 199 header_content_type = @headers.delete(RodaResponseHeaders::CONTENT_TYPE) 200 m.headers(@headers) 201 m.body(@body.join) unless @body.empty? 202 mail_attachments.each do |a, block| 203 m.add_file(*a) 204 block.call if block 205 end 206 207 if content_type = header_content_type || roda_class.mailer_opts[:content_type] 208 if mail.multipart? 209 if /multipart\/mixed/ =~ mail.content_type && 210 mail.parts.length >= 2 && 211 (part = mail.parts.find{|p| !p.attachment && (p.encoded; /text\/plain/ =~ p.content_type)}) 212 part.content_type = content_type 213 end 214 else 215 mail.content_type = content_type 216 end 217 end 218 219 unless m.body.to_s.empty? && m.parts.empty? && @body.empty? 220 m 221 end 222 else 223 super 224 end 225 end
mail_attachments()
The attachments related to the current mail.
[show source]
# File lib/roda/plugins/mailer.rb 228 def mail_attachments 229 @mail_attachments ||= [] 230 end