2012-01-25 13:32:51 -08:00
|
|
|
module Sidekiq
|
2012-03-10 12:30:15 -08:00
|
|
|
def self.hook_rails!
|
2012-09-20 20:04:25 -07:00
|
|
|
if defined?(::ActiveRecord)
|
|
|
|
::ActiveRecord::Base.send(:include, Sidekiq::Extensions::ActiveRecord)
|
2012-03-10 12:30:15 -08:00
|
|
|
end
|
|
|
|
|
2012-09-20 20:04:25 -07:00
|
|
|
if defined?(::ActionMailer)
|
|
|
|
::ActionMailer::Base.extend(Sidekiq::Extensions::ActionMailer)
|
2012-03-10 12:30:15 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-25 13:32:51 -08:00
|
|
|
class Rails < ::Rails::Engine
|
|
|
|
config.autoload_paths << File.expand_path("#{config.root}/app/workers") if File.exist?("#{config.root}/app/workers")
|
2012-03-10 12:30:15 -08:00
|
|
|
|
|
|
|
initializer 'sidekiq' do
|
|
|
|
Sidekiq.hook_rails!
|
|
|
|
end
|
|
|
|
end if defined?(::Rails)
|
2012-01-25 13:32:51 -08:00
|
|
|
end
|