Module: Roda::RodaPlugins::Mailer::ClassMethods
- Defined in:
- lib/roda/plugins/mailer.rb
Instance Method Summary collapse
-
#mail(path, *args) ⇒ Object
Return a Mail::Message instance for the email for the given request path and arguments.
-
#sendmail(*args) ⇒ Object
Calls
mail
and immediately sends the resulting mail.
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.
150 151 152 153 154 155 156 157 158 |
# File 'lib/roda/plugins/mailer.rb', line 150 def mail(path, *args) mail = ::Mail.new catch(:no_mail) do unless mail.equal?(new("PATH_INFO"=>path, 'SCRIPT_NAME'=>'', "REQUEST_METHOD"=>"MAIL", 'rack.input'=>StringIO.new, 'roda.mail'=>mail, 'roda.mail_args'=>args).call(&route_block)) raise Error, "route did not return mail instance for #{path.inspect}, #{args.inspect}" end mail end end |
#sendmail(*args) ⇒ Object
Calls mail
and immediately sends the resulting mail.
161 162 163 164 165 |
# File 'lib/roda/plugins/mailer.rb', line 161 def sendmail(*args) if m = mail(*args) m.deliver end end |