Module: Resque::Mailer::ClassMethods

Defined in:
lib/resque_mailer.rb

Instance Method Summary (collapse)

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method_name, *args)



38
39
40
41
42
43
44
# File 'lib/resque_mailer.rb', line 38

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

Instance Method Details

- (Object) current_env



30
31
32
33
34
35
36
# File 'lib/resque_mailer.rb', line 30

def current_env
  if defined?(Rails)
    ::Resque::Mailer.current_env || ::Rails.env
  else
    ::Resque::Mailer.current_env
  end
end

- (Boolean) deliver?



85
86
87
# File 'lib/resque_mailer.rb', line 85

def deliver?
  true
end

- (Boolean) excluded_environment?(name)



81
82
83
# File 'lib/resque_mailer.rb', line 81

def excluded_environment?(name)
  ::Resque::Mailer.excluded_environments && ::Resque::Mailer.excluded_environments.include?(name.try(:to_sym))
end

- (Object) perform(action, *args)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/resque_mailer.rb', line 46

def perform(action, *args)
  begin
    message = self.send(:new, action, *args).message
    message.deliver
  rescue Exception => ex
    if Mailer.error_handler
      if Mailer.error_handler.arity == 3
        warn "WARNING: error handlers with 3 arguments are deprecated and will be removed in the next release"
        Mailer.error_handler.call(self, message, ex)
      else
        Mailer.error_handler.call(self, message, ex, action, args)
      end
    else
      if logger
        logger.error "Unable to deliver email [#{action}]: #{ex}"
        logger.error ex.backtrace.join("\n\t")
      end

      raise ex
    end
  end
end

- (Object) queue



69
70
71
# File 'lib/resque_mailer.rb', line 69

def queue
  @queue || ::Resque::Mailer.default_queue_name
end

- (Object) queue=(name)



73
74
75
# File 'lib/resque_mailer.rb', line 73

def queue=(name)
  @queue = name
end

- (Object) resque



77
78
79
# File 'lib/resque_mailer.rb', line 77

def resque
  ::Resque::Mailer.default_queue_target
end