From 2496bf6fa8e49b8d5327d3d0f9e4b6c67e70fea8 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 15 Aug 2019 17:17:16 -0400 Subject: [PATCH] This fixes warnings on Ruby 2.7 (#1009) --- lib/faraday/adapter/em_http.rb | 4 ++-- lib/faraday/options.rb | 2 +- lib/faraday/response.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/faraday/adapter/em_http.rb b/lib/faraday/adapter/em_http.rb index 9e5380104..14bab4649 100644 --- a/lib/faraday/adapter/em_http.rb +++ b/lib/faraday/adapter/em_http.rb @@ -193,11 +193,11 @@ def reset def running?() @running end - def add + def add(&block) if running? perform_request { yield } else - @registered_procs << Proc.new + @registered_procs << block end @num_registered += 1 end diff --git a/lib/faraday/options.rb b/lib/faraday/options.rb index 95423496e..50cf60f47 100644 --- a/lib/faraday/options.rb +++ b/lib/faraday/options.rb @@ -72,7 +72,7 @@ def fetch(key, *args) if args.size > 0 send(key_setter, args.first) elsif block_given? - send(key_setter, Proc.new.call(key)) + send(key_setter, yield(key)) else raise self.class.fetch_error_class, "key not found: #{key.inspect}" end diff --git a/lib/faraday/response.rb b/lib/faraday/response.rb index 4c2573f7b..4c865e6c8 100644 --- a/lib/faraday/response.rb +++ b/lib/faraday/response.rb @@ -54,9 +54,9 @@ def finished? !!env end - def on_complete + def on_complete(&block) if not finished? - @on_complete_callbacks << Proc.new + @on_complete_callbacks << block else yield(env) end