diff options
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/async.rb | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/actionmailer/lib/action_mailer/async.rb b/actionmailer/lib/action_mailer/async.rb index fd62c57790..620f47f060 100644 --- a/actionmailer/lib/action_mailer/async.rb +++ b/actionmailer/lib/action_mailer/async.rb @@ -1,3 +1,5 @@ +require 'delegate' + module ActionMailer::Async def self.included(base) base.extend(ClassMethods) @@ -13,17 +15,19 @@ module ActionMailer::Async end end - class QueuedMessage - delegate :to_s, :to => :actual_message - + class QueuedMessage < ::Delegator def initialize(mailer_class, method_name, *args) @mailer_class = mailer_class @method_name = method_name *@args = *args end + def __getobj__ + @actual_message ||= @mailer_class.send(:new, @method_name, *@args).message + end + def run - actual_message.deliver + __getobj__.deliver end # Will push the message onto the Queue to be processed @@ -36,14 +40,5 @@ module ActionMailer::Async Rails.queue << self end end - - # The original ActionMailer message - def actual_message - @actual_message ||= @mailer_class.send(:new, @method_name, *@args).message - end - - def method_missing(method_name, *args) - actual_message.send(method_name, *args) - end end end |