Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generic argument forwarding + remove ruby2_keywords #1601

Merged
Merged
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
30 changes: 15 additions & 15 deletions lib/faraday/rack_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@ def locked?
@handlers.frozen?
end

ruby2_keywords def use(klass, *args, &block)
def use(klass, ...)
if klass.is_a? Symbol
use_symbol(Faraday::Middleware, klass, *args, &block)
use_symbol(Faraday::Middleware, klass, ...)
else
raise_if_locked
raise_if_adapter(klass)
@handlers << self.class::Handler.new(klass, *args, &block)
@handlers << self.class::Handler.new(klass, ...)
end
end

ruby2_keywords def request(key, *args, &block)
use_symbol(Faraday::Request, key, *args, &block)
def request(key, ...)
use_symbol(Faraday::Request, key, ...)
end

ruby2_keywords def response(key, *args, &block)
use_symbol(Faraday::Response, key, *args, &block)
def response(...)
use_symbol(Faraday::Response, ...)
end

ruby2_keywords def adapter(klass = NO_ARGUMENT, *args, &block)
Expand All @@ -115,25 +115,25 @@ def locked?

## methods to push onto the various positions in the stack:

ruby2_keywords def insert(index, *args, &block)
def insert(index, ...)
raise_if_locked
index = assert_index(index)
handler = self.class::Handler.new(*args, &block)
handler = self.class::Handler.new(...)
@handlers.insert(index, handler)
end

alias insert_before insert

ruby2_keywords def insert_after(index, *args, &block)
def insert_after(index, ...)
index = assert_index(index)
insert(index + 1, *args, &block)
insert(index + 1, ...)
end

ruby2_keywords def swap(index, *args, &block)
def swap(index, ...)
raise_if_locked
index = assert_index(index)
@handlers.delete_at(index)
insert(index, *args, &block)
insert(index, ...)
end

def delete(handler)
Expand Down Expand Up @@ -237,8 +237,8 @@ def is_adapter?(klass) # rubocop:disable Naming/PredicateName
klass <= Faraday::Adapter
end

ruby2_keywords def use_symbol(mod, key, *args, &block)
use(mod.lookup_middleware(key), *args, &block)
def use_symbol(mod, key, ...)
use(mod.lookup_middleware(key), ...)
end

def assert_index(index)
Expand Down
Loading