mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Use ruby2_keywords to pass keyword arguments correctly in delegation
Relocate ruby2_keywords gem dependency and `require` line Condition use of ruby2_keywords to avoid introducing gem dependency Drop superfluous newline
This commit is contained in:
parent
15d8aca0d7
commit
e767648e06
1 changed files with 5 additions and 3 deletions
|
@ -1943,10 +1943,12 @@ module Sinatra
|
|||
module Delegator #:nodoc:
|
||||
def self.delegate(*methods)
|
||||
methods.each do |method_name|
|
||||
define_method(method_name) do |*args, **options, &block|
|
||||
return super(*args, **options, &block) if respond_to? method_name
|
||||
Delegator.target.send(method_name, *args, **options, &block)
|
||||
define_method(method_name) do |*args, &block|
|
||||
return super(*args, &block) if respond_to? method_name
|
||||
Delegator.target.send(method_name, *args, &block)
|
||||
end
|
||||
# ensure keyword argument passing is compatible with ruby >= 2.7
|
||||
ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true)
|
||||
private method_name
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue