module Roda::RodaPlugins::MailProcessor::InstanceMethods

  1. lib/roda/plugins/mail_processor.rb

Public Instance methods

after_mail_hook()

Hook called after processing any mail, whether the mail was handled or not. Does nothing by default.

[show source]
    # File lib/roda/plugins/mail_processor.rb
415 def after_mail_hook
416   nil
417 end
handled_mail_hook()

Hook called after processing a mail, when the mail was handled. Does nothing by default.

[show source]
    # File lib/roda/plugins/mail_processor.rb
421 def handled_mail_hook
422   nil
423 end
mail()

The mail instance being processed.

[show source]
    # File lib/roda/plugins/mail_processor.rb
433 def mail
434   env['roda.mail']
435 end
mail_recipients()

The recipients of the mail instance being processed, uses the To and CC headers by default.

[show source]
    # File lib/roda/plugins/mail_processor.rb
445 def mail_recipients
446   Array(to) + Array(cc)
447 end
mail_text()

The text of the mail instance being processed, uses the decoded body of the mail by default.

[show source]
    # File lib/roda/plugins/mail_processor.rb
439 def mail_text
440   mail.body.decoded
441 end
process_mail(&block)

Perform the processing of mail for this request, first considering routes defined via the class-level rcpt method, and then the normal routing tree passed in as the block.

[show source]
    # File lib/roda/plugins/mail_processor.rb
387 def process_mail(&block)
388   if string_routes = self.class.mail_processor_string_routes
389     addresses = mail_recipients
390 
391     addresses.each do |address|
392       if meth = string_routes[address.to_s.downcase]
393         _roda_handle_route{send(meth, @_request)}
394         return
395       end
396     end
397 
398     self.class.mail_processor_regexp_routes.each do |regexp, meth|
399       addresses.each do |address|
400         if md = regexp.match(address)
401           _roda_handle_route{send(meth, @_request, *md.captures)}
402           return 
403         end
404       end
405     end
406   end
407 
408   _roda_handle_main_route
409 
410   nil
411 end
unhandled_mail(reason)

Raise an UnhandledMail exception with the given reason, used to mark the mail as not handled. A reason why the mail was not handled must be provided, which will be used as the exception message.

[show source]
    # File lib/roda/plugins/mail_processor.rb
452 def unhandled_mail(reason)
453   raise UnhandledMail, reason
454 end
unhandled_mail_hook()

Hook called after processing a mail, when the mail was not handled. Reraises the UnhandledMail exception raised during mail processing by default.

[show source]
    # File lib/roda/plugins/mail_processor.rb
428 def unhandled_mail_hook
429   raise
430 end