Created
December 9, 2013 02:18
-
-
Save invisiblefunnel/7866510 to your computer and use it in GitHub Desktop.
Mailers with Sidekiq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'devise/mailer' | |
| # | |
| # General mailer proxy class to send emails in the background w/ Sidekiq | |
| # | |
| class BackgroundMailer | |
| def self.reset_password_instructions(record, token, opts={}) | |
| new(Devise::Mailer, :reset_password_instructions, record, token, opts) | |
| end | |
| def initialize(mailer_klass, method, *args) | |
| @mailer_klass = mailer_klass | |
| @method = method | |
| @args = args | |
| end | |
| def deliver | |
| @mailer_klass.delay.send(@method, *@args) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment