1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Update how delayed extensions are loaded, fixes #3509

This commit is contained in:
Mike Perham 2017-06-16 08:47:34 -07:00
parent 980438c61d
commit ad98a32cbc
2 changed files with 24 additions and 3 deletions

View file

@ -2,11 +2,13 @@
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
HEAD
5.0.3
-----------
- Fix overriding `class_attribute` core extension from ActiveSupport with Sidekiq one [PikachuEXE, #3499]
- Allow job logger to be overridden [AlfonsoUceda, #3502]
- Set a default Redis client identifier for debugging [#3516]
- Fix "Uninitialized constant" errors on startup with the delayed extensions [#3509]
5.0.2
-----------

View file

@ -3,12 +3,17 @@ module Sidekiq
def self.enable_delay!
if defined?(::ActiveSupport)
ActiveSupport.on_load(:active_record) do
require 'sidekiq/extensions/active_record'
require 'sidekiq/extensions/action_mailer'
# Need to patch Psych so it can autoload classes whose names are serialized
# in the delayed YAML.
Psych::Visitors::ToRuby.prepend(Sidekiq::Extensions::PsychAutoload)
ActiveSupport.on_load(:active_record) do
include Sidekiq::Extensions::ActiveRecord
end
ActiveSupport.on_load(:action_mailer) do
require 'sidekiq/extensions/action_mailer'
extend Sidekiq::Extensions::ActionMailer
end
end
@ -17,5 +22,19 @@ module Sidekiq
Module.__send__(:include, Sidekiq::Extensions::Klass)
end
module PsychAutoload
def resolve_class(klass_name)
# constantize
names = klass_name.split('::')
names.shift if names.empty? || names.first.empty?
names.inject(Object) do |constant, name|
constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
end
rescue NameError
super
end
end
end
end