Class: Delayed::PerformableMailer

Inherits:
PerformableMethod show all
Defined in:
lib/delayed/shallow_mongoid/performable_mailer.rb

Instance Attribute Summary

Attributes inherited from PerformableMethod

#args, #method_name, #object

Instance Method Summary collapse

Methods inherited from PerformableMethod

#display_name, #initialize

Constructor Details

This class inherits a constructor from Delayed::PerformableMethod

Instance Method Details

#performObject



3
4
5
6
7
8
9
10
# File 'lib/delayed/shallow_mongoid/performable_mailer.rb', line 3

def perform
  klass = ShallowMongoid.load(object)
  delayed_arguments = *args.map { |a| ShallowMongoid.load(a) }
  message = klass.send(method_name, *delayed_arguments)
  message.respond_to?(:deliver_now) ? message.deliver_now : message.deliver
rescue Delayed::ShallowMongoid::Errors::DocumentNotFound
  return true # do nothing if document has been removed
end