Class: Fog::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Connection

Returns a new instance of Connection.



4
5
6
# File 'lib/fog/connection.rb', line 4

def initialize(url)
  @excon = Excon.new(url)
end

Instance Method Details

#request(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/connection.rb', line 8

def request(params)
  if parser = params.delete(:parser)
    body = Nokogiri::XML::SAX::PushParser.new(parser)
    params[:block] = lambda { |chunk| body << chunk }
  end

  response = @excon.request(params)

  if parser
    body.finish
    response.body = parser.response
  end

  response
end