1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/action_mailroom/router.rb
2018-09-17 22:15:27 -07:00

18 lines
358 B
Ruby

require "byebug"
class ActionMailroom::Router
def initialize(routes)
@routes = routes
end
def route(inbound_email)
locate_mailbox(inbound_email).receive(inbound_email)
end
private
attr_reader :routes
def locate_mailbox(inbound_email)
"#{routes[inbound_email.mail.to.first].to_s.capitalize}Mailbox".constantize
end
end