Class: ActionMailbox::Router
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Exceptions:
| |
Inherits: | Object |
Defined in: | actionmailbox/lib/action_mailbox/router.rb |
Overview
Encapsulates the routes that live on the ApplicationMailbox and performs the actual routing when an inbound_email is received.
Class Method Summary
- .new ⇒ Router constructor
Instance Method Summary
Constructor Details
.new ⇒ Router
# File 'actionmailbox/lib/action_mailbox/router.rb', line 9
def initialize @routes = [] end
Instance Method Details
#add_route(address, to:)
[ GitHub ]#add_routes(routes)
[ GitHub ]# File 'actionmailbox/lib/action_mailbox/router.rb', line 13
def add_routes(routes) routes.each do |(address, mailbox_name)| add_route address, to: mailbox_name end end
#mailbox_for(inbound_email)
[ GitHub ]#route(inbound_email)
[ GitHub ]# File 'actionmailbox/lib/action_mailbox/router.rb', line 23
def route(inbound_email) if mailbox = mailbox_for(inbound_email) mailbox.receive(inbound_email) else inbound_email.bounced! raise RoutingError end end