Sha256: f5bf687b0f58532fff9de04166a1cf745a49d89e5c338e6e484d0cb85b20bbe6

Contents?: true

Size: 1.04 KB

Versions: 27

Compression:

Stored size: 1.04 KB

Contents

module Sidekiq
  def self.hook_rails!
    return if defined?(@delay_removed)

    ActiveSupport.on_load(:active_record) do
      include Sidekiq::Extensions::ActiveRecord
    end

    ActiveSupport.on_load(:action_mailer) do
      extend Sidekiq::Extensions::ActionMailer
    end

    Module.__send__(:include, Sidekiq::Extensions::Klass)
  end

  # Removes the generic aliases which MAY clash with names of already
  #  created methods by other applications. The methods `sidekiq_delay`,
  #  `sidekiq_delay_for` and `sidekiq_delay_until` can be used instead.
  def self.remove_delay!
    @delay_removed = true

    [Extensions::ActiveRecord,
     Extensions::ActionMailer,
     Extensions::Klass].each do |mod|
      mod.module_eval do
        remove_method :delay if respond_to?(:delay)
        remove_method :delay_for if respond_to?(:delay_for)
        remove_method :delay_until if respond_to?(:delay_until)
      end
    end
  end

  class Rails < ::Rails::Engine
    initializer 'sidekiq' do
      Sidekiq.hook_rails!
    end
  end if defined?(::Rails)
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
sidekiq-4.1.1 lib/sidekiq/rails.rb
sidekiq-4.1.0 lib/sidekiq/rails.rb
sidekiq-3.5.4 lib/sidekiq/rails.rb
sidekiq-4.0.2 lib/sidekiq/rails.rb
sidekiq-4.0.1 lib/sidekiq/rails.rb
sidekiq-4.0.0 lib/sidekiq/rails.rb
sidekiq-4.0.0.pre2 lib/sidekiq/rails.rb
sidekiq-3.5.3 lib/sidekiq/rails.rb
sidekiq-4.0.0.pre1 lib/sidekiq/rails.rb
sidekiq-3.5.2 lib/sidekiq/rails.rb
sidekiq-3.5.1 lib/sidekiq/rails.rb
sidekiq-3.5.0 lib/sidekiq/rails.rb
sidekiq-3.4.2 lib/sidekiq/rails.rb
sidekiq-3.4.1 lib/sidekiq/rails.rb
sidekiq-3.4.0 lib/sidekiq/rails.rb
sidekiq-3.3.4 lib/sidekiq/rails.rb
sidekiq-3.3.3 lib/sidekiq/rails.rb
sidekiq-3.3.2 lib/sidekiq/rails.rb
sidekiq-3.3.1 lib/sidekiq/rails.rb
sidekiq-3.3.0 lib/sidekiq/rails.rb