nebulab / simple_command

A simple, standardized way to build and use Service Objects (aka Commands) in Ruby
http://nebulab.it
MIT License
625 stars 55 forks source link

Using Ruby 3 style keyword arguments raises warning in Ruby 2.7 #27

Closed rgraff closed 4 years ago

rgraff commented 4 years ago
class ExampleCommand
  prepend SimpleCommand
  def initialize(foo:)
    @foo = foo
  end
  def call
    @foo
  end
end

irb(main):010:0> ExampleCommand.call(foo: "bar")
/usr/local/bundle/gems/simple_command-0.1.0/lib/simple_command.rb:9: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
(irb):3: warning: The called method `initialize' is defined here
=> #<ExampleCommand:0x0000560f7af7f988 @foo="bar", @called=true, @result="bar">

The issue is describe here: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

The warning is in 2.7 and will error in 3.0

rgraff commented 4 years ago

PR here: https://github.com/nebulab/simple_command/pull/28