1 # Copyright 2010 Google Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 module Google #:nodoc:
16 class APIClient #:nodoc:
18 # Factory for HTTP backed client requests.
22 # The default transport configuration values. These may be overridden
23 # simply by passing in the same key to the constructor.
25 :parser => :json_parser
29 # The default implementations of various parsers. These may be overriden
30 # simply by passing the same key to the constructor.
32 :json_parser => JSONParser.new
36 # Creates a new HTTP request factory.
38 # @param [Hash] options
39 # @return [Google::APIClient::Discovery] The HTTP request factory.
40 def initialize(options={})
41 @options = DEFAULTS.clone
42 @options.merge!(options)
44 # first check if user passed a parser then fallback on appropriate default
45 @parser = @options[@options[:parser]] || PARSERS[@options[:parser]]
48 'Invalid :parser configuration.'
53 # Returns configuration of the transport.
55 # @return [Hash] The configuration options.
61 # Returns the parser used by the transport.
63 # @return The handle to the parser.