From 7fa848684bae0bb879d2142155947b73decc555a Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Wed, 27 Nov 2019 20:09:32 +0100 Subject: [PATCH] [Ruby 2.7] Stops using `&Proc.new` for block forwarding. Back-port 5ace0ea5ab82b49bb13648dcfd0272d068a82885 --- lib/faraday.rb | 3 +-- lib/faraday/rack_builder.rb | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/faraday.rb b/lib/faraday.rb index 80db124c9..7a829766d 100644 --- a/lib/faraday.rb +++ b/lib/faraday.rb @@ -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 diff --git a/lib/faraday/rack_builder.rb b/lib/faraday/rack_builder.rb index e3641e25c..13950ee22 100644 --- a/lib/faraday/rack_builder.rb +++ b/lib/faraday/rack_builder.rb @@ -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