Sha256: 28befc4eaa4346c7bc963820d7d0f1060d4c47e23dae9a0f6db2844f9c9b14b6

Contents?: true

Size: 719 Bytes

Versions: 3

Compression:

Stored size: 719 Bytes

Contents

require "queue_classic"

module QC
  module Mailer

    class MessageDecoy
      delegate :to_s, :to => :actual_message

      def initialize(mailer_class, method_name, *args)
        @mailer_class   = mailer_class
        @method_name    = method_name.to_s
        *@args          = *args
      end

      def actual_message
        @actual_message ||= @mailer_class.send(:new, @method_name, *@args).message
      end

      def deliver
        @mailer_class.queue.enqueue("#{@mailer_class}.deliver", @method_name, *@args)
      end

      def deliver!
        actual_message.deliver
      end

      def method_missing(method_name, *args)
        actual_message.send(method_name, *args)
      end
    end
  
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qc-mailer-0.0.3 lib/qc-mailer/message_decoy.rb
qc-mailer-0.0.2 lib/qc-mailer/message_decoy.rb
qc-mailer-0.0.1 lib/qc-mailer/message_decoy.rb