From 88e214803de49bdde2b8b7d157a98d49a79e2742 Mon Sep 17 00:00:00 2001 From: Patrik Ragnarsson Date: Wed, 16 Feb 2022 22:49:43 +0100 Subject: [PATCH] Use `ruby2_keywords` for delegation Follows the "The Only Correct Way" from https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html Related to https://github.com/sinatra/sinatra/pull/1670 Fixes https://github.com/sinatra/sinatra/issues/1749 --- lib/sinatra/base.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 6ced0a6d48..986fe455d6 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -1533,10 +1533,11 @@ def prototype # Create a new instance of the class fronted by its middleware # pipeline. The object is guaranteed to respond to #call but may not be # an instance of the class new was called on. - def new(*args, **kwargs, &bk) - instance = new!(*args, **kwargs, &bk) + def new(*args, &bk) + instance = new!(*args, &bk) Wrapper.new(build(instance).to_app, instance) end + ruby2_keywords :new if respond_to?(:ruby2_keywords, true) # Creates a Rack::Builder instance with all the middleware set up and # the given +app+ as end point.