Sha256: c3872115540d4790d81027fd0623db0c455fe7fd6660a53e3146b64f517e6d5c

Contents?: true

Size: 848 Bytes

Versions: 2

Compression:

Stored size: 848 Bytes

Contents

module Resque
  module Mailer

    class Rails3MailerProxy
      def initialize(mailer_class, action, *args)
        @mailer_class = mailer_class
        @action = action
        @args = args
      end

      def deliver
        ::Resque.enqueue(@mailer_class, @action, *@args)
      end

      def deliver!
        @mailer_class.send(:new, @action, *@args).message.deliver
      end
    end

    module ClassMethods

      def current_env
        ::Rails.env
      end

      def method_missing(method_name, *args)
        return super if environment_excluded?

        if action_methods.include?(method_name.to_s)
          Rails3MailerProxy.new(self, method_name, *args)
        else
          super
        end
      end

      def perform(action, *args)
        Rails3MailerProxy.new(self, action, *args).deliver!
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resque_mailer-1.0.1 lib/resque_mailer/rails3.rb
resque_mailer-1.0.0 lib/resque_mailer/rails3.rb