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
#method_missing(method_name, *args) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/resque_mailer.rb', line 25
def method_missing(method_name, *args)
return super if environment_excluded?
if action_methods.include?(method_name.to_s)
MessageDecoy.new(self, method_name, *args)
else
super
end
end
|
Instance Method Details
#current_env ⇒ Object
21
22
23
|
# File 'lib/resque_mailer.rb', line 21
def current_env
::Rails.env
end
|
#deliver? ⇒ Boolean
55
56
57
|
# File 'lib/resque_mailer.rb', line 55
def deliver?
true
end
|
#environment_excluded? ⇒ Boolean
39
40
41
|
# File 'lib/resque_mailer.rb', line 39
def environment_excluded?
!ActionMailer::Base.perform_deliveries || excluded_environment?(current_env)
end
|
#excluded_environment?(name) ⇒ Boolean
35
36
37
|
# File 'lib/resque_mailer.rb', line 35
def perform(action, *args)
self.send(:new, action, *args.map { |o| o.is_a?(Hash) && o.has_key?("class_name") && o.has_key?("id") ? o["class_name"].constantize.find(o["id"]) : o }).message.deliver
end
|