lib/faraday/connection.rb in faraday-0.5.7 vs lib/faraday/connection.rb in faraday-0.6.0

- old
+ new

@@ -20,24 +20,22 @@ def initialize(url = nil, options = {}) if url.is_a?(Hash) options = url url = options[:url] end - @headers = HeaderHash.new + @headers = Headers.new @params = {} @options = options[:request] || {} @ssl = options[:ssl] || {} @parallel_manager = options[:parallel] self.url_prefix = url if url proxy(options[:proxy]) merge_params @params, options[:params] if options[:params] merge_headers @headers, options[:headers] if options[:headers] if block_given? - block = Proc.new - @builder = Builder.new - @builder.build { block.call(self) } + @builder = Builder.create { |b| yield b } else @builder = options[:builder] || Builder.new end end @@ -119,11 +117,11 @@ @proxy = case arg when String then {:uri => proxy_arg_to_uri(arg)} when URI then {:uri => arg} - when Hash then arg + when Hash if arg[:uri] = proxy_arg_to_uri(arg[:uri]) arg else raise ArgumentError, "no :uri option." end @@ -160,14 +158,9 @@ if value value.chomp! "/" value.replace "/#{value}" if value !~ /^\// end @path_prefix = value - end - - # return the assembled Rack application for this instance. - def to_app - @builder.to_app end def run_request(method, url, body, headers) if !METHODS.include?(method) raise ArgumentError, "unknown http method: #{method}"