Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Inject locale into Resque::Mailer and Devise::Async
require 'resque_mailer'
require 'devise/async'
# pop and set locale from the args before running
module PerformWithLocale
def perform(*args)
I18n.with_locale(args.pop) do
super(*args)
end
end
end
module DeliverWithLocale
def deliver
# @args are not used when rendered inline, only when enqueueing
@args << I18n.locale.to_s
super
end
end
#= resque_mailer locale support
if defined?(Resque::Mailer)
module Resque::Mailer
# push locale onto the args when queueing
MessageDecoy.send :prepend, DeliverWithLocale
# pop when dequeueing
ClassMethods.send :prepend, PerformWithLocale
end
end
#= devise/async locale support
if defined?(Devise::Async)
module Devise::Async
module EnqueueWithLocale
def enqueue(*args)
super *(args + [I18n.locale])
end
end
class Worker
class << self
prepend Devise::Async::EnqueueWithLocale
end
end
class Backend::Resque
class << self
prepend PerformWithLocale
end
end
end
end
@glebm
Owner

requires ruby 2 and this devise-async PR mhfs/devise-async#37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.