2012-01-25 16:32:51 -05:00
|
|
|
module Sidekiq
|
2012-03-10 15:30:15 -05:00
|
|
|
def self.hook_rails!
|
2014-03-28 20:36:38 -04:00
|
|
|
ActiveSupport.on_load(:active_record) do
|
|
|
|
include Sidekiq::Extensions::ActiveRecord
|
2012-03-10 15:30:15 -05:00
|
|
|
end
|
|
|
|
|
2014-03-28 20:36:38 -04:00
|
|
|
ActiveSupport.on_load(:action_mailer) do
|
|
|
|
extend Sidekiq::Extensions::ActionMailer
|
2012-03-10 15:30:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-04-24 10:11:05 -04:00
|
|
|
# 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.
|
2014-05-20 23:42:25 -04:00
|
|
|
def self.remove_delay!
|
|
|
|
[Extensions::ActiveRecord,
|
|
|
|
Extensions::ActionMailer,
|
2014-04-24 10:11:05 -04:00
|
|
|
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
|
|
|
|
|
2012-01-25 16:32:51 -05:00
|
|
|
class Rails < ::Rails::Engine
|
2012-03-10 15:30:15 -05:00
|
|
|
initializer 'sidekiq' do
|
|
|
|
Sidekiq.hook_rails!
|
|
|
|
end
|
|
|
|
end if defined?(::Rails)
|
2012-01-25 16:32:51 -05:00
|
|
|
end
|