-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
ActiveJob should support passing of keyword arguments to perform method #18741
Comments
This appears to be due to the hash getting converted to string keys during job serialization/deserialization, while keyword arguments only work with symbol keyed hashes. |
Unfortunately, the HashWithIndifferent access approach is insufficient for our needs. It's perfectly reasonable to want to use keyword arguments with Active Job, which we will see as a symbol keyed hash. For Ruby to convert this back to keyword arguments, it must deserialize to a symbol keyed hash. There are two primary changes to the serialization behavior. We first treat a HWIA separately, and mark it as such so we can convert it back into a HWIA during deserialization. For normal hashes, we keep a list of all symbol keys, and convert them back to symbol keys after deserialization. Fixes #18741. Conflicts: activejob/CHANGELOG.md
Backported in 31085a5 |
@sgrif Impressive. I was going to start hacking on it after I got back from lunch, but you beat me to it. Thank you. |
This is awesome. I was testing it out with Ruby 4.2.4 and noticed that if you mix keyword and regular arguments it doesn't work. For example:
Won't work and gives you a
Does. |
curious, can I use it for |
Since Rails 5+ will required Ruby 2.2+, ActiveJob should support the passing of keyword arguments to the perform method.
Currently (rails 4.2), you get a
ArgumentError: wrong number of arguments (1 for 0)
if you try to pass keyword arguments.The text was updated successfully, but these errors were encountered: