diff options
Diffstat (limited to 'app/models/mailer.rb')
-rw-r--r-- | app/models/mailer.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 22b99edf6..96bb83c57 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -372,6 +372,17 @@ class Mailer < ActionMailer::Base ActionMailer::Base.perform_deliveries = was_enabled end + # Sends emails synchronously in the given block + def self.with_synched_deliveries(&block) + saved_method = ActionMailer::Base.delivery_method + if m = saved_method.to_s.match(%r{^async_(.+)$}) + ActionMailer::Base.delivery_method = m[1].to_sym + end + yield + ensure + ActionMailer::Base.delivery_method = saved_method + end + private def initialize_defaults(method_name) super |