Sha256: e0ba27477637a55191a89643acd0a6708e51373a5a690649163c251976a50be5
Contents?: true
Size: 823 Bytes
Versions: 4
Compression:
Stored size: 823 Bytes
Contents
module Qe module Locale def self.included(base) unless base.included_modules.include?(Qe::Worker) raise OutOfOrderError, "must be included after Qe::Worker" end class << base # Intercept <tt>Worker.enqueue</tt> method, adding # the current locale to the options. enqueue = instance_method(:enqueue) define_method :enqueue do |options = {}| options[:locale] ||= I18n.locale enqueue.bind(self).call(options) end end base.class_eval do # Intercept <tt>Worker#before</tt> method and # set the current locale. before = instance_method(:before) define_method :before do I18n.locale = options.delete(:locale) before.bind(self).call end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
qe-0.4.0 | lib/qe/locale.rb |
qe-0.3.5 | lib/qe/locale.rb |
qe-0.3.4 | lib/qe/locale.rb |
qe-0.3.3 | lib/qe/locale.rb |