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
412 def after_mail_hook
413   nil
414 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
418 def handled_mail_hook
419   nil
420 end
mail()

The mail instance being processed.

[show source]
    # File lib/roda/plugins/mail_processor.rb
430 def mail
431   env['roda.mail']
432 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
442 def mail_recipients
443   Array(to) + Array(cc)
444 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
436 def mail_text
437   mail.body.decoded
438 end
process_mail(&block)

Perform the processing of mail for this request, first considering routes defined via the 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
384 def process_mail(&block)
385   if string_routes = opts[:mail_processor_string_routes]
386     addresses = mail_recipients
387 
388     addresses.each do |address|
389       if meth = string_routes[address.to_s.downcase]
390         _roda_handle_route{send(meth, @_request)}
391         return
392       end
393     end
394 
395     opts[:mail_processor_regexp_routes].each do |regexp, meth|
396       addresses.each do |address|
397         if md = regexp.match(address)
398           _roda_handle_route{send(meth, @_request, *md.captures)}
399           return 
400         end
401       end
402     end
403   end
404 
405   _roda_handle_main_route
406 
407   nil
408 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
449 def unhandled_mail(reason)
450   raise UnhandledMail, reason
451 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
425 def unhandled_mail_hook
426   raise
427 end