1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Stick with match concept

This commit is contained in:
David Heinemeier Hansson 2018-09-20 17:27:41 -07:00
parent 3fc8e5325f
commit 43bd726442

View file

@ -16,7 +16,7 @@ class ActionMailroom::Router
end end
def route(inbound_email) def route(inbound_email)
if mailbox = locate_mailbox(inbound_email) if mailbox = match_to_mailbox(inbound_email)
mailbox.receive(inbound_email) mailbox.receive(inbound_email)
else else
raise RoutingError raise RoutingError
@ -26,7 +26,7 @@ class ActionMailroom::Router
private private
attr_reader :routes attr_reader :routes
def locate_mailbox(inbound_email) def match_to_mailbox(inbound_email)
routes.detect { |route| route.match?(inbound_email) }.try(:mailbox_class) routes.detect { |route| route.match?(inbound_email) }.try(:mailbox_class)
end end
end end