Skip to content

Commit

Permalink
set correct scope for all jobs in a generic way also for retries
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbauer authored and wvengen committed Feb 6, 2025
1 parent b2deb0e commit e91fc18
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion config/initializers/active_job_select_foodcoop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,29 @@ def serialize(arguments)
end

def deserialize(arguments)
FoodsoftConfig.select_multifoodcoop arguments.shift
FoodsoftConfig.select_multifoodcoop arguments[0]
orig_deserialize(arguments)
end
end
end
end

module ActiveJob
module Execution
# Store the original `_perform_job` method
original_perform_job = instance_method(:_perform_job)

# Override the `_perform_job` method
define_method(:_perform_job) do
foodsoft_scope = @arguments.shift
FoodsoftConfig.select_foodcoop foodsoft_scope

# Call the original `_perform_job` method
original_perform_job.bind(self).call
end
end
end

ActiveSupport.on_load(:after_initialize) do
ActiveJob::Arguments.include FoodsoftActiveJobArguments
end

0 comments on commit e91fc18

Please sign in to comment.