mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Use ActiveSupport.on_load hooks to extend rails components
Checking if the constant is define and including the extensions directly in the base class will for the class to be loaded. This may cause these components to be loaded before the time and be missconfigured if the sidekiq railtie is loaded before the components railtie. It is unlikely to happen but is better be safe.
This commit is contained in:
parent
dabd1f5be9
commit
499882d4d4
1 changed files with 4 additions and 4 deletions
|
@ -1,11 +1,11 @@
|
||||||
module Sidekiq
|
module Sidekiq
|
||||||
def self.hook_rails!
|
def self.hook_rails!
|
||||||
if defined?(::ActiveRecord)
|
ActiveSupport.on_load(:active_record) do
|
||||||
::ActiveRecord::Base.__send__(:include, Sidekiq::Extensions::ActiveRecord)
|
include Sidekiq::Extensions::ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
if defined?(::ActionMailer)
|
ActiveSupport.on_load(:action_mailer) do
|
||||||
::ActionMailer::Base.extend(Sidekiq::Extensions::ActionMailer)
|
extend Sidekiq::Extensions::ActionMailer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue