I can not use keyword parameters in dry-transaction match blocks in Ruby 3.0.
This code sample works on Ruby 2.7 but returns an error on 3.0:
require "dry/transaction"
class DoSomething
include Dry::Transaction
step :run
private
def run
Success(a: 1, b: 2)
end
end
DoSomething.new.call do |m|
m.success { |a:, b:| puts "#{a}#{b}" }
m.failure {}
end
Exception raised:
ArgumentError: missing keywords: :a, :b
From what I understand keyword parameters in Ruby 3.0 should be passed with a double splat operator and maybe that’s the problem?
https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/#typical-cases
Or am I doing something wrong?