Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Fix keyword argument passing in Ruby 3 #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/middleware/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ def flatten
# of the middleware.
#
# @param [Class] middleware The middleware class
def use(middleware, *args, &block)
def use(middleware, *args, **kwargs, &block)
if middleware.kind_of?(Builder)
# Merge in the other builder's stack into our own
self.stack.concat(middleware.stack)
else
self.stack << [middleware, args, block]
self.stack << [middleware, args, kwargs, block]
end

self
Expand Down
4 changes: 2 additions & 2 deletions lib/middleware/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def build_call_chain(stack)
# is always the empty middleware, which does nothing but return.
stack.reverse.inject(EMPTY_MIDDLEWARE) do |next_middleware, current_middleware|
# Unpack the actual item
klass, args, block = current_middleware
klass, args, kwargs, block = current_middleware

# Default the arguments to an empty array. Otherwise in Ruby 1.8
# a `nil` args will actually pass `nil` into the class. Not what
Expand All @@ -52,7 +52,7 @@ def build_call_chain(stack)
if klass.is_a?(Class)
# If the klass actually is a class, then instantiate it with
# the app and any other arguments given.
klass.new(next_middleware, *args, &block)
klass.new(next_middleware, *args, **kwargs, &block)
elsif klass.respond_to?(:call)
# Make it a lambda which calls the item then forwards up
# the chain.
Expand Down