lib/httpx/session.rb in httpx-0.10.2 vs lib/httpx/session.rb in httpx-0.11.0
- old
+ new
@@ -39,11 +39,11 @@
end
def build_request(verb, uri, options = EMPTY_HASH)
rklass = @options.request_class
request = rklass.new(verb, uri, @options.merge(options).merge(persistent: @persistent))
- request.on(:response, &method(:on_response).curry[request])
+ request.on(:response, &method(:on_response).curry(2)[request])
request.on(:promise, &method(:on_promise))
request
end
private
@@ -134,26 +134,23 @@
end
def build_requests(*args, options)
request_options = @options.merge(options)
- requests = case args.size
- when 1
- reqs = args.first
- reqs.map do |verb, uri, opts = EMPTY_HASH|
- build_request(verb, uri, request_options.merge(opts))
- end
- when 2
- verb, uris = args
- if uris.respond_to?(:each)
- uris.enum_for(:each).map do |uri, opts = EMPTY_HASH|
- build_request(verb, uri, request_options.merge(opts))
- end
- else
- [build_request(verb, uris, request_options)]
- end
- else
- raise ArgumentError, "unsupported number of arguments"
+ requests = if args.size == 1
+ reqs = args.first
+ reqs.map do |verb, uri, opts = EMPTY_HASH|
+ build_request(verb, uri, request_options.merge(opts))
+ end
+ else
+ verb, uris = args
+ if uris.respond_to?(:each)
+ uris.enum_for(:each).map do |uri, opts = EMPTY_HASH|
+ build_request(verb, uri, request_options.merge(opts))
+ end
+ else
+ [build_request(verb, uris, request_options)]
+ end
end
raise ArgumentError, "wrong number of URIs (given 0, expect 1..+1)" if requests.empty?
requests
end