Class: Fog::Connection

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

Instance Method Summary collapse

Constructor Details

#initialize(url, persistent = false, params = {}) ⇒ Connection

Returns a new instance of Connection.



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

def initialize(url, persistent=false, params={})
  @excon = Excon.new(url, params)
  @persistent = persistent
end

Instance Method Details

#request(params, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/core/connection.rb', line 9

def request(params, &block)
  unless @persistent
    reset
  end
  unless block_given?
    if (parser = params.delete(:parser))
      body = Nokogiri::XML::SAX::PushParser.new(parser)
      block = lambda { |chunk| body << chunk }
    end
  end

  response = @excon.request(params, &block)

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

  response
end

#resetObject



30
31
32
# File 'lib/fog/core/connection.rb', line 30

def reset
  @excon.reset
end