Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby 2.7] Stops using &Proc.new for block forwarding. #1083

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def self.attribute_options
@attribute_options ||= {}
end

def self.memoized(key)
memoized_attributes[key.to_sym] = Proc.new
def self.memoized(key, &block)
memoized_attributes[key.to_sym] = block
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{key}() self[:#{key}]; end
RUBY
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