Skip to content

Commit

Permalink
Merge pull request #18 from hoenth/master
Browse files Browse the repository at this point in the history
Defer include until after initialization
  • Loading branch information
will89 authored Jan 29, 2021
2 parents a069aee + 3c92b72 commit bf02ac1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/delayed/job_groups/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module Delayed
module JobGroups
class Railtie < ::Rails::Railtie
config.after_initialize do
Delayed::Backend::ActiveRecord::Job.include(Delayed::JobGroups::JobExtensions)
end
end
end
end
11 changes: 10 additions & 1 deletion lib/delayed_job_groups_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
require 'delayed/job_groups/yaml_loader'
require 'delayed/job_groups/version'

Delayed::Backend::ActiveRecord::Job.send(:include, Delayed::JobGroups::JobExtensions)
if defined?(Delayed::Backend::ActiveRecord)
if defined?(Rails::Railtie)
# Postpone initialization to railtie for correct order
require 'delayed/job_groups/railtie'
else
# Do the same as in the railtie
Delayed::Backend::ActiveRecord::Job.include(Delayed::JobGroups::JobExtensions)
end
end


Delayed::Worker.plugins << Delayed::JobGroups::Plugin

0 comments on commit bf02ac1

Please sign in to comment.