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 2.7 warnings #672
Comments
@the-spectator Interested in resolving this issue ? |
I also discovered this topic: https://bugs.ruby-lang.org/issues/16463 |
@anilmaurya Yes, I will definitely try to resolve the issues. |
Hi @hwo411 I checked this issue. You should not use keyword argument in
Closing this issue, please reopen if it does not solve your problem. |
@anilmaurya does this mean that aasm won't support keyword arguments for transitions? It's worth adding to the documentation then. I'm not familiar with aasm code, but brief check showed me that |
@hwo411 Currently AASM support array of arguments, using hash & keyword argument together will throw this warning in 2.7. |
@anilmaurya Since I just stumbled across this, currently the README actually recommends using keyword arguments (https://github.com/aasm/aasm#parameters): |
Thank you @tisba for pointing it out, I have corrected it. |
Just to get this clarified: Hash/Keyword arguments, like in the example below, in guards, callbacks etc. are currently not supported, correct? (although they just work in Ruby <= 2.6) class Job
include AASM
aasm do
state :idle
state :running
event :run do
transitions from: :idle, to: :running do
after do |reason:|
self.reason = reason
puts "reason was #{reason}"
end
end
end
end
end
job = Job.new
job.run(reason: 'my-reason')
# => Ruby 2.6 just works
# => Ruby 2.7 prints deprecation warning as described in this issue
# => Ruby 3.0 raises "missing keyword: :reason (ArgumentError)" Out of curiosity, and because I personally like the keyword style much more: Will it stay this way? Is there a technical reason for that? Or is it "just" a hell lot of work? I would be happy to help to get this working if it is something the maintainers would consider valuable. I'd even say it is something, that should be supported in a way newer Ruby version would expect it to work. There is no way, I as a reader of that code, could know this would blow up on newer Rubies. |
I also don't understand why it is closed as a "won't fix". Would it be possible to provide a bit more details on why? |
Describe the bug
Right now having
after_enter
method with keyword generates a warning with Ruby 2.7:``usr/local/bundle/ruby/2.7.0/gems/aasm-5.0.8/lib/aasm/core/invokers/literal_invoker.rb:32: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call`
To Reproduce
I didn't test this code, this is an extraction from our working code.
Expected behavior
No Ruby 2.7 warnings are shown.
The text was updated successfully, but these errors were encountered: