diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-17 17:49:47 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-17 17:49:47 -0700 |
commit | 061d77f7ca949b55c313c1cbbd7b48e65f0aa569 (patch) | |
tree | 007967fa5f3bf6f3afb84f84de0804630e30d4a9 /lib | |
parent | 03b18410071f4e8a9a2daff13e02881e5f1a1c12 (diff) | |
download | rails-061d77f7ca949b55c313c1cbbd7b48e65f0aa569.tar.gz rails-061d77f7ca949b55c313c1cbbd7b48e65f0aa569.tar.bz2 rails-061d77f7ca949b55c313c1cbbd7b48e65f0aa569.zip |
WIP: Router
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_mailroom.rb | 1 | ||||
-rw-r--r-- | lib/action_mailroom/mailbox.rb | 19 | ||||
-rw-r--r-- | lib/action_mailroom/router.rb | 16 |
3 files changed, 36 insertions, 0 deletions
diff --git a/lib/action_mailroom.rb b/lib/action_mailroom.rb index 5dc0d5a11c..e50d1c4ebe 100644 --- a/lib/action_mailroom.rb +++ b/lib/action_mailroom.rb @@ -4,4 +4,5 @@ module ActionMailroom extend ActiveSupport::Autoload autoload :Mailbox + autoload :Router end diff --git a/lib/action_mailroom/mailbox.rb b/lib/action_mailroom/mailbox.rb index e19e6d7c6d..e873b55544 100644 --- a/lib/action_mailroom/mailbox.rb +++ b/lib/action_mailroom/mailbox.rb @@ -1,2 +1,21 @@ class ActionMailroom::Mailbox + class << self + def receive(inbound_email) + new(inbound_email).process + end + + def routing(routes) + @router = ActionMailroom::Router.new(routes) + end + end + + attr_reader :inbound_email + delegate :mail, to: :inbound_email + + def initialize(inbound_email) + @inbound_email = inbound_email + end + + def process + end end diff --git a/lib/action_mailroom/router.rb b/lib/action_mailroom/router.rb new file mode 100644 index 0000000000..8ce3947337 --- /dev/null +++ b/lib/action_mailroom/router.rb @@ -0,0 +1,16 @@ +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].to_s.capitalize}Mailbox" + end +end |