Skip to content

Commit

Permalink
Use generic argument forwarding + remove ruby2_keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
chaymaeBZ authored and olleolleolle committed Nov 26, 2024
1 parent 93ef9e0 commit f9f4ce5
Showing 1 changed file with 15 additions and 15 deletions.
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

0 comments on commit f9f4ce5

Please sign in to comment.