2012-01-25 16:32:51 -05:00
|
|
|
module Sidekiq
|
2012-03-10 15:30:15 -05:00
|
|
|
def self.hook_rails!
|
2012-09-20 23:04:25 -04:00
|
|
|
if defined?(::ActiveRecord)
|
|
|
|
::ActiveRecord::Base.send(:include, Sidekiq::Extensions::ActiveRecord)
|
2012-03-10 15:30:15 -05:00
|
|
|
end
|
|
|
|
|
2012-09-20 23:04:25 -04:00
|
|
|
if defined?(::ActionMailer)
|
|
|
|
::ActionMailer::Base.extend(Sidekiq::Extensions::ActionMailer)
|
2012-03-10 15:30:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-25 16:32:51 -05: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 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
|