parens are allright in my book

This commit is contained in:
rick 2010-09-07 11:38:46 -07:00
parent 48cbbac378
commit c1fdbe3e02
5 changed files with 16 additions and 16 deletions

View File

@ -56,19 +56,19 @@ module Faraday
end
def request(key, *args, &block)
use_symbol Faraday::Request, key, *args, &block
use_symbol(Faraday::Request, key, *args, &block)
end
def response(key, *args, &block)
use_symbol Faraday::Response, key, *args, &block
use_symbol(Faraday::Response, key, *args, &block)
end
def adapter(key, *args, &block)
use_symbol Faraday::Adapter, key, *args, &block
use_symbol(Faraday::Adapter, key, *args, &block)
end
def use_symbol(mod, key, *args, &block)
use mod.lookup_module(key), *args, &block
use(mod.lookup_module(key), *args, &block)
end
def ==(other)
@ -76,7 +76,7 @@ module Faraday
end
def dup
self.class.new @handlers.dup
self.class.new(@handlers.dup)
end
end
end

View File

@ -74,23 +74,23 @@ module Faraday
end
def get(url = nil, headers = nil, &block)
run_request :get, url, nil, headers, &block
run_request(:get, url, nil, headers, &block)
end
def post(url = nil, body = nil, headers = nil, &block)
run_request :post, url, body, headers, &block
run_request(:post, url, body, headers, &block)
end
def put(url = nil, body = nil, headers = nil, &block)
run_request :put, url, body, headers, &block
run_request(:put, url, body, headers, &block)
end
def head(url = nil, headers = nil, &block)
run_request :head, url, nil, headers, &block
run_request(:head, url, nil, headers, &block)
end
def delete(url = nil, headers = nil, &block)
run_request :delete, url, nil, headers, &block
run_request(:delete, url, nil, headers, &block)
end
def basic_auth(login, pass)
@ -217,10 +217,10 @@ module Faraday
def replace_query(uri, params)
url_params = @params.dup
if uri.query && !uri.query.empty?
merge_params url_params, parse_query(uri.query)
merge_params(url_params, parse_query(uri.query))
end
if params && !params.empty?
merge_params url_params, params
merge_params(url_params, params)
end
uri.query = url_params.empty? ? nil : build_query(url_params)
uri

View File

@ -65,8 +65,8 @@ module Faraday
def to_env_hash(connection, request_method)
env_headers = connection.headers.dup
env_params = connection.params.dup
connection.merge_headers env_headers, headers
connection.merge_params env_params, params
connection.merge_headers(env_headers, headers)
connection.merge_params(env_params, params)
{ :method => request_method,
:body => body,

View File

@ -13,7 +13,7 @@ module Faraday
def call(env)
env[:request_headers]['Content-Type'] = 'application/json'
if env[:body] && !env[:body].respond_to?(:to_str)
env[:body] = ActiveSupport::JSON.encode env[:body]
env[:body] = ActiveSupport::JSON.encode(env[:body])
end
@app.call env
end

View File

@ -10,7 +10,7 @@ module Faraday
def call(env)
env[:request_headers]['Content-Type'] = 'application/json'
if env[:body] && !env[:body].respond_to?(:to_str)
env[:body] = Yajl::Encoder.encode env[:body]
env[:body] = Yajl::Encoder.encode(env[:body])
end
@app.call env
end