Sha256: ea22698c4e85b317890f7a5684f6f0828504dcd8bf205105d782b2c7f0809baa

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Sidekiq # :nodoc:
  module Extensions
    def self.enable_delay!
      warn "Sidekiq's Delayed Extensions will be removed in Sidekiq 7.0", uplevel: 1

      if defined?(::ActiveSupport)
        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
          extend Sidekiq::Extensions::ActionMailer
        end
      end

      require "sidekiq/extensions/class_methods"
      Module.__send__(:include, Sidekiq::Extensions::Klass)
    end

    module PsychAutoload
      def resolve_class(klass_name)
        return nil if !klass_name || klass_name.empty?
        # 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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sidekiq-6.5.12 lib/sidekiq/delay.rb
sidekiq-6.5.11 lib/sidekiq/delay.rb
sidekiq-6.5.10 lib/sidekiq/delay.rb
sidekiq-6.5.9 lib/sidekiq/delay.rb
sidekiq-6.5.8 lib/sidekiq/delay.rb
sidekiq-6.5.7 lib/sidekiq/delay.rb
sidekiq-6.5.6 lib/sidekiq/delay.rb
sidekiq-6.5.5 lib/sidekiq/delay.rb
sidekiq-6.5.4 lib/sidekiq/delay.rb
sidekiq-6.5.3 lib/sidekiq/delay.rb
sidekiq-6.5.2 lib/sidekiq/delay.rb
sidekiq-6.5.1 lib/sidekiq/delay.rb