-
Notifications
You must be signed in to change notification settings - Fork 9
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
Ruby 3 support #6
Comments
Great callout! Thank you! Our focus for this gem has been to shift it towards using ActiveJob as the primary end-developer API, and ActiveJob performables already fully support Ruby 3.0 kwargs. That said, we have not removed or reworked the existing Longer term, we may choose to extract all of the |
Oh if the ActiveJob (perform_later?) API works with Ruby 3 this issue is moot. |
Resolves #6. While we already fully support Ruby 3.0 kwargs via ActiveJob, the legacy `delay` and `handle_asynchronously` APIs did not support the new [separation of positional and keyword arguments](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/) introduced in 2.7 and enforced in 3.0. This means that methods accepting both positional and keyword arguments (e.g. `def foo(a, b:)`) would fail with a `wrong number of arguments (given 2, expected 1; required keyword:)` error on Ruby 3. In order to resolve this, this PR changes `Delayed::PerformableMethod` to handle kwargs separately from args, with a backwards compatibility check for any Ruby 2.6 methods that do not accept keyword arguments. It should also support jobs that were enqueued by the prior `delayed` gem version (where the new `kwargs` accessor would be nil, and `args` contains the kwargs as its last item).
Ruby 3 changed the way it handles keyword arguments, and is a roadblock with delayed_job. I checked the relevant bits in the source of this gem (at least the bits that used to be relevant in delayed_job) and didn't see any changes or fixes for Ruby 3 keyword argument handling.
delayed/lib/delayed/message_sending.rb
Lines 11 to 13 in 2d296b9
delayed/lib/delayed/performable_method.rb
Lines 25 to 27 in 2d296b9
While the gemspec suggests Ruby 3 should work, does it really?
The text was updated successfully, but these errors were encountered: