module Roda::RodaPlugins::MailProcessor::InstanceMethods
Public Instance Methods
Source
# File lib/roda/plugins/mail_processor.rb, line 412 def after_mail_hook nil end
Hook called after processing any mail, whether the mail was handled or not. Does nothing by default.
Source
# File lib/roda/plugins/mail_processor.rb, line 418 def handled_mail_hook nil end
Hook called after processing a mail, when the mail was handled. Does nothing by default.
Source
# File lib/roda/plugins/mail_processor.rb, line 430 def mail env['roda.mail'] end
The mail instance being processed.
Source
# File lib/roda/plugins/mail_processor.rb, line 442 def mail_recipients Array(to) + Array(cc) end
The recipients of the mail instance being processed, uses the To and CC headers by default.
Source
# File lib/roda/plugins/mail_processor.rb, line 436 def mail_text mail.body.decoded end
The text of the mail instance being processed, uses the decoded body of the mail by default.
Source
# File lib/roda/plugins/mail_processor.rb, line 384 def process_mail(&block) if string_routes = opts[:mail_processor_string_routes] addresses = mail_recipients addresses.each do |address| if meth = string_routes[address.to_s.downcase] _roda_handle_route{send(meth, @_request)} return end end opts[:mail_processor_regexp_routes].each do |regexp, meth| addresses.each do |address| if md = regexp.match(address) _roda_handle_route{send(meth, @_request, *md.captures)} return end end end end _roda_handle_main_route nil end
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.
Source
# File lib/roda/plugins/mail_processor.rb, line 449 def unhandled_mail(reason) raise UnhandledMail, reason end
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.
Source
# File lib/roda/plugins/mail_processor.rb, line 425 def unhandled_mail_hook raise end
Hook called after processing a mail, when the mail was not handled. Reraises the UnhandledMail
exception raised during mail processing by default.