Skip to content

Commit

Permalink
[Ruby 2.7] Stops using &Proc.new for block forwarding.
Browse files Browse the repository at this point in the history
Back-port 5ace0ea
  • Loading branch information
olleolleolle committed Nov 27, 2019
1 parent 9865ebb commit 7fa8486
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/faraday.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ class << self
# :params => {:page => 1}
#
# Returns a Faraday::Connection.
def new(url = nil, options = nil)
block = block_given? ? Proc.new : nil
def new(url = nil, options = nil, &block)
options = options ? default_connection_options.merge(options) : default_connection_options
Faraday::Connection.new(url, options, &block)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/faraday/rack_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def build(app)
end
end

def initialize(handlers = [])
def initialize(handlers = [], &block)
@handlers = handlers
if block_given?
build(&Proc.new)
build(&block)
elsif @handlers.empty?
# default stack, if nothing else is configured
self.request :url_encoded
Expand Down

0 comments on commit 7fa8486

Please sign in to comment.