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/options.rb b/lib/faraday/options.rb index 50cf60f47..b17342780 100644 --- a/lib/faraday/options.rb +++ b/lib/faraday/options.rb @@ -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 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