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.



242
243
244
245
# File 'lib/roda/plugins/mailer.rb', line 242

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.



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

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.



248
249
250
# File 'lib/roda/plugins/mailer.rb', line 248

def no_mail!
  throw :no_mail
end