aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailbox/lib/action_mailbox/router.rb
diff options
context:
space:
mode:
authorJames Dabbs <jamesdabbs@gmail.com>2019-05-04 10:53:08 -0700
committerJames Dabbs <jamesdabbs@gmail.com>2019-05-04 10:53:08 -0700
commit9f96d094a39100df53ea68b8bd6fa7fcafd96eac (patch)
tree237fec97bcb99065be3d464f25f2fa69bf34b6d0 /actionmailbox/lib/action_mailbox/router.rb
parentac1ba44f8d46ebbbe6889629d263e5690631f6a1 (diff)
downloadrails-9f96d094a39100df53ea68b8bd6fa7fcafd96eac.tar.gz
rails-9f96d094a39100df53ea68b8bd6fa7fcafd96eac.tar.bz2
rails-9f96d094a39100df53ea68b8bd6fa7fcafd96eac.zip
Expose `mailbox_for` method
Currently, the only exposed entry point into the ApplicationMailbox's configured routing system is to call `route`, which performs a lot of work to fully `process` inbound email. It'd be nice to have a way (e.g. in test) of checking which mailbox an email would route to without necessarily processing it yet.
Diffstat (limited to 'actionmailbox/lib/action_mailbox/router.rb')
-rw-r--r--actionmailbox/lib/action_mailbox/router.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/actionmailbox/lib/action_mailbox/router.rb b/actionmailbox/lib/action_mailbox/router.rb
index 71370e409d..54982eae21 100644
--- a/actionmailbox/lib/action_mailbox/router.rb
+++ b/actionmailbox/lib/action_mailbox/router.rb
@@ -21,7 +21,7 @@ module ActionMailbox
end
def route(inbound_email)
- if mailbox = match_to_mailbox(inbound_email)
+ if mailbox = mailbox_for(inbound_email)
mailbox.receive(inbound_email)
else
inbound_email.bounced!
@@ -30,12 +30,12 @@ module ActionMailbox
end
end
+ def mailbox_for(inbound_email)
+ routes.detect { |route| route.match?(inbound_email) }.try(:mailbox_class)
+ end
+
private
attr_reader :routes
-
- def match_to_mailbox(inbound_email)
- routes.detect { |route| route.match?(inbound_email) }.try(:mailbox_class)
- end
end
end