Module: Roda::RodaPlugins::Mailer::InstanceMethods

Defined in:
lib/roda/plugins/mailer.rb

Instance Method Summary collapse

Instance Method Details

#add_file(*a, &block) ⇒ Object

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.



255
256
257
258
# File 'lib/roda/plugins/mailer.rb', line 255

def add_file(*a, &block)
  response.mail_attachments << [a, block]
  nil
end

#initialize(env) ⇒ Object

If this is an email request, set the mail object in the response, as well as the default content_type for the email.



243
244
245
246
247
248
249
250
# File 'lib/roda/plugins/mailer.rb', line 243

def initialize(env)
  super
  if mail = env['roda.mail']
    res = @_response
    res.mail = mail
    res.headers.delete('Content-Type')
  end
end

#no_mail!Object

Signal that no mail should be sent for this request.



261
262
263
# File 'lib/roda/plugins/mailer.rb', line 261

def no_mail!
  throw :no_mail
end