module Roda::RodaPlugins::Mailer::InstanceMethods
Public Class Methods
Source
# File lib/roda/plugins/mailer.rb, line 245 def initialize(env) super if mail = env['roda.mail'] res = @_response res.mail = mail res.headers.delete(RodaResponseHeaders::CONTENT_TYPE) end end
If this is an email request, set the mail object in the response, as well as the default content_type for the email.
Calls superclass method
Public Instance Methods
Source
# File lib/roda/plugins/mailer.rb, line 257 def add_file(*a, &block) response.mail_attachments << [a, block] nil end
Delay adding a file to the message until after the message body has been set. If a block is given, the block is called after the file has been added, and you can access the attachment via response.mail_attachments.last
.
Source
# File lib/roda/plugins/mailer.rb, line 263 def no_mail! throw :no_mail end
Signal that no mail should be sent for this request.
Private Instance Methods
Source
# File lib/roda/plugins/mailer.rb, line 271 def _mail_part(meth, body, headers=nil) env['roda.mail'].public_send(meth) do body(body) headers(headers) if headers end nil end
Set the text_part or html_part (depending on the method) in the related email, using the given body and optional headers.