Class: Sidekiq::Extensions::DelayedMailer
- Inherits:
-
Object
- Object
- Sidekiq::Extensions::DelayedMailer
- Includes:
- Worker
- Defined in:
- lib/sidekiq/extensions/action_mailer.rb
Overview
Adds ‘delay’, ‘delay_for’ and ‘delay_until` methods to ActionMailer to offload arbitrary email delivery to Sidekiq. Example:
UserMailer.delay.send_welcome_email(new_user)
UserMailer.delay_for(5.days).send_welcome_email(new_user)
UserMailer.delay_until(5.days.from_now).send_welcome_email(new_user)
Instance Attribute Summary
Attributes included from Worker
Instance Method Summary collapse
Methods included from Worker
clear_all, drain_all, included, jobs, #logger
Instance Method Details
#perform(yml) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sidekiq/extensions/action_mailer.rb', line 15 def perform(yml) (target, method_name, args) = YAML.load(yml) msg = target.public_send(method_name, *args) # The email method can return nil, which causes ActionMailer to return # an undeliverable empty message. if msg deliver(msg) else raise "#{target.name}##{method_name} returned an undeliverable mail object" end end |