From 89ada1977ce648b2121cad7cfb95af9686ea016b Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Wed, 17 Oct 2018 10:54:58 -0400 Subject: Remove unnecessary TODO Exception handlers are executed in the context of a mailbox instance and already have access to the inbound email. --- lib/action_mailbox/base.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/action_mailbox') diff --git a/lib/action_mailbox/base.rb b/lib/action_mailbox/base.rb index 3b12493662..103bbc544c 100644 --- a/lib/action_mailbox/base.rb +++ b/lib/action_mailbox/base.rb @@ -27,7 +27,6 @@ class ActionMailbox::Base end end rescue => exception - # TODO: Include a reference to the inbound_email in the exception raised so error handling becomes easier rescue_with_handler(exception) || raise end -- cgit v1.2.3 From 7903e3ada80d7938b1b78b06d0f678e95367a56b Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Wed, 17 Oct 2018 12:38:26 -0400 Subject: Use a class attribute --- lib/action_mailbox/routing.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/action_mailbox') diff --git a/lib/action_mailbox/routing.rb b/lib/action_mailbox/routing.rb index b40e2774e4..d258b632f9 100644 --- a/lib/action_mailbox/routing.rb +++ b/lib/action_mailbox/routing.rb @@ -2,15 +2,17 @@ module ActionMailbox module Routing extend ActiveSupport::Concern - class_methods do - attr_reader :router + included do + cattr_accessor :router, default: ActionMailbox::Router.new + end + class_methods do def routing(routes) - (@router ||= ActionMailbox::Router.new).add_routes(routes) + router.add_routes(routes) end def route(inbound_email) - @router.route(inbound_email) + router.route(inbound_email) end end end -- cgit v1.2.3 From 2b09cbbe4407ce84b23450b27b2c3b6f35e8ef1b Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Wed, 17 Oct 2018 12:42:54 -0400 Subject: Shush various interpreter warnings --- lib/action_mailbox/base.rb | 2 +- lib/action_mailbox/test_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/action_mailbox') diff --git a/lib/action_mailbox/base.rb b/lib/action_mailbox/base.rb index 103bbc544c..01ddc9c59b 100644 --- a/lib/action_mailbox/base.rb +++ b/lib/action_mailbox/base.rb @@ -49,7 +49,7 @@ class ActionMailbox::Base inbound_email.processing! yield inbound_email.delivered! unless inbound_email.bounced? - rescue => exception + rescue inbound_email.failed! raise end diff --git a/lib/action_mailbox/test_helper.rb b/lib/action_mailbox/test_helper.rb index b1d7af33f9..a74ea8ef57 100644 --- a/lib/action_mailbox/test_helper.rb +++ b/lib/action_mailbox/test_helper.rb @@ -9,7 +9,7 @@ module ActionMailbox end def create_inbound_email_from_mail(status: :processing, **mail_options) - raw_email = Tempfile.new.tap { |raw_email| raw_email.write Mail.new(mail_options).to_s } + raw_email = Tempfile.new.tap { |io| io.write Mail.new(mail_options).to_s } create_inbound_email(raw_email, status: status) end -- cgit v1.2.3 From cf8d76fdb42ab33c778b1787fb2ebe06481e2e3f Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Wed, 17 Oct 2018 13:22:52 -0400 Subject: Revert "Remove unnecessary TODO" This reverts commit 89ada1977ce648b2121cad7cfb95af9686ea016b. --- lib/action_mailbox/base.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/action_mailbox') diff --git a/lib/action_mailbox/base.rb b/lib/action_mailbox/base.rb index 01ddc9c59b..30ecc4b623 100644 --- a/lib/action_mailbox/base.rb +++ b/lib/action_mailbox/base.rb @@ -27,6 +27,7 @@ class ActionMailbox::Base end end rescue => exception + # TODO: Include a reference to the inbound_email in the exception raised so error handling becomes easier rescue_with_handler(exception) || raise end -- cgit v1.2.3