module Roda::RodaPlugins::MailProcessor::ClassMethods

def freeze

Freeze the rcpt routes if they are present.
def freeze
  if string_routes = opts[:mail_processor_string_routes].freeze
    string_routes.freeze
    opts[:mail_processor_regexp_routes].freeze
  end
  super
end

def process_mail(mail)

whether the mail was handled during processing.
Process the given Mail instance, calling the appropriate hooks depending on
def process_mail(mail)
  scope = new("PATH_INFO"=>'', 'SCRIPT_NAME'=>'', "REQUEST_METHOD"=>"PROCESSMAIL", 'rack.input'=>StringIO.new, 'roda.mail'=>mail)
  begin
    begin
      scope.process_mail
    rescue UnhandledMail
      scope.unhandled_mail_hook
    else
      scope.handled_mail_hook
    end
  ensure
    scope.after_mail_hook
  end
end

def process_mailbox(opts=OPTS)

the +after_mail+ method should be used to perform the archiving of the mail.
not reprocess the same mail. If mail should be archived and not deleted,
mailbox after processing, so that when called multiple times it does
uses the default Mail retriever_method. This deletes retrieved mail from the
given, should be an object supporting the Mail retriever API, otherwise
Process all mail in the given mailbox. If the +:retriever+ option is
def process_mailbox(opts=OPTS)
  (opts[:retriever] || Mail).find_and_delete(opts.dup){|m| process_mail(m)}
  nil
end

def rcpt(*addresses, &block)

of the normal routing tree.
Any messages matching the given recipient address will use these routing trees instead
Setup a routing tree for the given recipient addresses, which can be strings or regexps.
def rcpt(*addresses, &block)
  opts[:mail_processor_string_routes] ||= {}
  opts[:mail_processor_regexp_routes] ||= {}
  string_meth = nil
  regexp_meth = nil
  addresses.each do |address|
    case address
    when String
      unless string_meth
        string_meth = define_roda_method("mail_processor_string_route_#{address}", 1, &convert_route_block(block))
      end
      opts[:mail_processor_string_routes][address] = string_meth 
    when Regexp
      unless regexp_meth
        regexp_meth = define_roda_method("mail_processor_regexp_route_#{address}", :any, &convert_route_block(block))
      end
      opts[:mail_processor_regexp_routes][address] = regexp_meth
    else
      raise RodaError, "invalid address format passed to rcpt, should be Array or String"
    end
  end
  nil
end