2012-01-25 16:32:51 -05:00
|
|
|
module Sidekiq
|
2012-03-10 15:30:15 -05:00
|
|
|
def self.hook_rails!
|
2012-03-26 19:05:33 -04:00
|
|
|
return unless Sidekiq.options[:enable_rails_extensions]
|
2012-03-10 15:30:15 -05:00
|
|
|
if defined?(ActiveRecord)
|
|
|
|
ActiveRecord::Base.send(:include, Sidekiq::Extensions::ActiveRecord)
|
|
|
|
end
|
|
|
|
|
|
|
|
if defined?(ActionMailer)
|
|
|
|
ActionMailer::Base.extend(Sidekiq::Extensions::ActionMailer)
|
|
|
|
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
|