blob: 80a0517bff94de6a41ca045c7eb17befe330e086 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
require 'delegate'
module ActionMailer
class MessageDelivery < Delegator
def initialize(mailer, mail_method, *args)
@mailer = mailer
@mail_method = mail_method
@args = args
end
def __getobj__
@obj ||= @mailer.send(:new, @mail_method, *@args).message
end
def __setobj__(obj)
@obj = obj
end
def message #:nodoc:
__getobj__
end
def deliver_later!(options={})
enqueue_delivery :deliver!, options
end
def deliver_later(options={})
enqueue_delivery :deliver, options
end
private
def enqueue_delivery(delivery_method, options={})
args = @mailer.name, @mail_method.to_s, delivery_method.to_s, *@args
enqueue_method = :enqueue
if options[:at]
enqueue_method = :enqueue_at
args.unshift options[:at]
elsif options[:in]
enqueue_method = :enqueue_in
args.unshift options[:in]
end
ActionMailer::DeliveryJob.send enqueue_method, *args
end
end
end
|