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.



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

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.



232
233
234
235
236
237
238
239
# File 'lib/roda/plugins/mailer.rb', line 232

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.



250
251
252
# File 'lib/roda/plugins/mailer.rb', line 250

def no_mail!
  throw :no_mail
end