8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/typekit/connection/adaptor/standard.rb', line 8
def process(method, address, parameters = {}, = {})
klass = Net::HTTP.const_get(method.to_s.capitalize)
request = klass.new(build_uri(address, parameters))
.each { |k, v| request[k] = v }
http = Net::HTTP.new(request.uri.host, request.uri.port)
http.use_ssl = true if address =~ /^https:/
response = http.request(request)
[ response.code, response.to_hash, response.body ]
rescue NameError
raise Error, 'Invalid method'
rescue SocketError
raise Error, 'Connection failed'
end
|