Skip to content

Commit

Permalink
Declare DependencyLoader#new with ruby2_keywords to fix Ruby 3.2.0
Browse files Browse the repository at this point in the history
When adding a middleware that receives keyword arguments in the
constructor, the call from `DependencyLoader#new` fails because
the method is not defined using `ruby2_keywords`.

This adds the required `ruby2_keywords` declaration to
`DependencyLoader#new`, fixing the tests and getting Faraday v1.x
working with Ruby 3.2.0.

Fixes lostisland#1479.
  • Loading branch information
timrogers committed Jan 18, 2023
1 parent 68025fa commit d064c47
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/faraday/dependency_loader.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'ruby2_keywords'

module Faraday
# DependencyLoader helps Faraday adapters and middleware load dependencies.
module DependencyLoader
Expand All @@ -13,7 +15,7 @@ def dependency(lib = nil)
self.load_error = e
end

def new(*)
ruby2_keywords def new(*)
unless loaded?
raise "missing dependency for #{self}: #{load_error.message}"
end
Expand Down

0 comments on commit d064c47

Please sign in to comment.