class ActionMailbox::Router

an inbound_email is received.
Encapsulates the routes that live on the ApplicationMailbox and performs the actual routing when

def add_route(address, to:)

def add_route(address, to:)
  routes.append Route.new(address, to: to)
end

def add_routes(routes)

def add_routes(routes)
  routes.each do |(address, mailbox_name)|
    add_route address, to: mailbox_name
  end
end

def initialize

def initialize
  @routes = []
end

def match_to_mailbox(inbound_email)

def match_to_mailbox(inbound_email)
  routes.detect { |route| route.match?(inbound_email) }.try(:mailbox_class)
end

def route(inbound_email)

def route(inbound_email)
  if mailbox = match_to_mailbox(inbound_email)
    mailbox.receive(inbound_email)
  else
    inbound_email.bounced!
    raise RoutingError
  end
end