aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_mailroom/router.rb
blob: be2a980927e821e8d4d1ebf2734c57ffaefef7cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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