Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass item in after_unlock callback #665

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,22 @@ def worker_class

# The hook to call after a successful unlock
# @return [Proc]
def after_unlock_hook
def after_unlock_hook # rubocop:disable Metrics/MethodLength
lambda do
if @worker_class.respond_to?(:after_unlock)
@worker_class.after_unlock # instance method in sidekiq v6
# instance method in sidekiq v6
if @worker_class.method(:after_unlock).arity.positive? # arity check to maintain backwards compatibility
@worker_class.after_unlock(item)
else
@worker_class.after_unlock
end
elsif worker_class.respond_to?(:after_unlock)
worker_class.after_unlock # class method regardless of sidekiq version
# class method regardless of sidekiq version
if worker_class.method(:after_unlock).arity.positive? # arity check to maintain backwards compatibility
worker_class.after_unlock(item)
else
worker_class.after_unlock
end
end
end
end
Expand Down