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

fix: unable to use keyword args when including the Labels extension #1500

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

ElMassimo
Copy link
Contributor

@ElMassimo ElMassimo commented Oct 8, 2024

Description 📖

This pull request fixes a bug which is described in:

Background 📜

For backwards compatibility, activejob uses ruby2_keywords to capture arguments that are passed to perform_now and perform_later.

That ensures that it can serialize and deserialize keyword arguments differently.

GoodJob::ActiveJobExtensions::Labels overrides the initialize method, but it does not use ruby2_keywords, so by the time activejob receives the arguments, keyword arguments have become a plain Hash.

The Fix 🔨

Passing all arguments as-is, by using ... instead of *arguments, since the module doesn't need to use the parameters.

Notes ✏️

Using ruby2_keywords(:initialize) would also work, but since this library no longer supports CRuby 2.6 and 2.7, ... is the way to go.

@bensheldon
Copy link
Owner

Thanks @ElMassimo. That makes sense about ruby2_keywords being the piece that allows the initialize(*arguments) method signature to handle kwargs.

I'm happy with this change. You're right that we do finally have ... support 👍🏻

@bensheldon bensheldon added the bug Something isn't working label Oct 8, 2024
@bensheldon bensheldon merged commit 7020bec into bensheldon:main Oct 8, 2024
10 checks passed
@ElMassimo ElMassimo deleted the fix/kwargs branch October 8, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

2 participants