Skip to content

Commit

Permalink
Use ruby2_keywords for delegation
Browse files Browse the repository at this point in the history
Follows the "The Only Correct Way" from https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html

Related to #1670
Fixes #1749
  • Loading branch information
dentarg authored and jkowens committed Apr 14, 2022
1 parent c4608c8 commit 3dd160b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/sinatra/base.rb
Expand Up @@ -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.
Expand Down

0 comments on commit 3dd160b

Please sign in to comment.