1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use new ... syntax in Module#delegate if it's available

It was added in https://bugs.ruby-lang.org/issues/16253

It allows to do blind delegation without having to worry
about ruby2_keywords, and suposedly is also a bit faster.
This commit is contained in:
Jean Boussier 2019-12-18 16:05:20 +01:00
parent 6da2152d60
commit 11ac92ef79

View file

@ -199,7 +199,13 @@ class Module
# Attribute writer methods only accept one argument. Makes sure []=
# methods still accept two arguments.
definition = /[^\]]=$/.match?(method) ? "arg" : "*args, &block"
definition = if /[^\]]=$/.match?(method)
"arg"
elsif RUBY_VERSION >= "2.7"
"..."
else
"*args, &block"
end
# The following generated method calls the target exactly once, storing
# the returned value in a dummy variable.