Allow both `current_page?(url_hash)` and `current_page?(**url_hash)` on Ruby 2.7

Keyword argument warnings are caused by #41206 to allow both
`current_page?(url_hash)` and `current_page?(**url_hash)` on Ruby 3.0.

Unfortunately it is super hard to support that for both Ruby 2.7 and 3.0
with the same method signature.

Closes #41710.
This commit is contained in:
Ryuta Kamizono 2021-03-22 10:49:18 +09:00
parent 8c7883d3fc
commit 81d90d81d0
1 changed files with 13 additions and 0 deletions

View File

@ -577,6 +577,19 @@ module ActionView
end
end
if RUBY_VERSION.start_with?("2.7")
using Module.new {
refine UrlHelper do
alias :_current_page? :current_page?
end
}
def current_page?(*args) # :nodoc:
options = args.pop
options.is_a?(Hash) ? _current_page?(*args, **options) : _current_page?(*args, options)
end
end
# Creates an SMS anchor link tag to the specified +phone_number+. When the
# link is clicked, the default SMS messaging app is opened ready to send a
# message to the linked phone number. If the +body+ option is specified,