I have several methods that take many (keyword) arguments that end up passing the same set of arguments along to another method.
The following is normal.
def foo(a:, b:, c:, d:, e:)
bar('var', a:a, b:b, c:c, d:d, e:e)
end
# takes the same arguments as #foo + one more
def bar(var, a:, b:, c:, d:, e:)
...
end
This is just kind of tedious and annoying. I'm wondering if there is anything in the Ruby core that would make it easy to do the following...
def foo(a:, b:, c:, d:, e:)
bar('var', <something that automagically collects all of the keyword args>)
end
I know that you can parse over method(__method__).parameters, do some gymnastics, and package everything up into a hash that could be double-splatted and passed to bar. I'm just wondering if there is already something in the core that does that in a nice, neat way?
If there is something that applies in a more general way, i.e. not only to keyword args, then that's certainly interesting too.