Module: Roda::RodaPlugins::Mailer::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#mail(path, *args) ⇒ Object

Return a Mail::Message instance for the email for the given request path and arguments. You can further manipulate the returned mail object before calling deliver to send the mail.



128
129
130
131
132
133
134
# File 'lib/roda/plugins/mailer.rb', line 128

def mail(path, *args)
  mail = ::Mail.new
  unless mail.equal?(allocate.call(PATH_INFO=>path, SCRIPT_NAME=>EMPTY_STRING, REQUEST_METHOD=>MAIL, RACK_INPUT=>StringIO.new, RODA_MAIL=>mail, RODA_MAIL_ARGS=>args, &route_block))
    raise Error, "route did not return mail instance for #{path.inspect}, #{args.inspect}"
  end
  mail
end

#sendmail(*args) ⇒ Object

Calls mail and immediately sends the resulting mail.



137
138
139
# File 'lib/roda/plugins/mailer.rb', line 137

def sendmail(*args)
  mail(*args).deliver
end