Sha256: 29c6dd5c8b395395682a47966a34897decc83739de0adf77f47ec57dee9822ba

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 Bytes

Contents

require "active_support/concern"
require "qc-mailer/version"
require "qc-mailer/message_decoy"

module QC
  module Mailer
    extend ActiveSupport::Concern

    included do 
      extend(ClassMethods)
    end
      
    # ModuleMethods
    mattr_accessor :default_queue
    def self.default_queue
      @@default_queue || QC::QUEUE || "default"
    end

    # ClassMethods
    module ClassMethods
      def queue_name
        @queue_name || QC::Mailer.default_queue
      end

      def queue_name=(val)
        @queue_name = val
      end

      def queue
        @queue ||= QC::Queue.new(queue_name)
      end

      def deliver(method, *args)
        send(method, *args).deliver!
      end

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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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