Module: Resque::Mailer

Defined in:
lib/merb_resque_mailer.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.excluded_environmentsObject



10
11
12
# File 'lib/merb_resque_mailer.rb', line 10

def self.excluded_environments
  @@excluded_environments ||= [:test]
end

.excluded_environments=(*environments) ⇒ Object



6
7
8
# File 'lib/merb_resque_mailer.rb', line 6

def self.excluded_environments=(*environments)
  @@excluded_environments = environments && environments.flatten.collect! { |env| env.to_sym }
end

.included(base) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/merb_resque_mailer.rb', line 14

def self.included(base)
  base.extend(ClassMethods)
  base.class_eval do
    alias_method :dispatch_and_deliver!, :dispatch_and_deliver
    
    def dispatch_and_deliver(method, mail_params)
      if ::Resque::Mailer.excluded_environments.include?(Merb.env.to_sym)
        dispatch_and_deliver!(method, mail_params)
      else
        ::Resque.enqueue(self.class, @params, method, mail_params)
      end
    end
  end
end