Module: Gnarly::Client::Patron

Defined in:
lib/gnarly/client/patron.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.http(request, opts = {}) ⇒ Object



26
27
28
# File 'lib/gnarly/client/patron.rb', line 26

def self.http(request, opts={})
  Object.new.extend(self).http request, opts
end

Instance Method Details

#http(request, opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gnarly/client/patron.rb', line 11

def http(request, opts={})
  method, url, headers, body = request
  session = ::Patron::Session.new
  session.timeout = opts[:timeout] if opts[:timeout]
  options = {}
  options[:data] = body if body
  r = session.request method, Client.create_url(url), headers, options
  response = [r.status, Client.symbolize_headers(r.headers), r.body]
  if block_given?
    yield response
  else
    response
  end
end