Class: Fog::Connection
- Inherits:
-
Object
- Object
- Fog::Connection
- Defined in:
- lib/fog/core/connection.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(url, persistent = false, params = {}) ⇒ Connection
constructor
A new instance of Connection.
- #request(params, &block) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(url, persistent = false, params = {}) ⇒ Connection
Returns a new instance of Connection.
4 5 6 7 8 |
# File 'lib/fog/core/connection.rb', line 4 def initialize(url, persistent=false, params={}) Excon.defaults[:headers]['User-Agent'] ||= "fog/#{Fog::VERSION}" @excon = Excon.new(url, params) @persistent = persistent end |
Instance Method Details
#request(params, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fog/core/connection.rb', line 10 def request(params, &block) unless @persistent reset end unless block_given? if (parser = params.delete(:parser)) body = Nokogiri::XML::SAX::PushParser.new(parser) params[:response_block] = lambda { |chunk, remaining, total| body << chunk } end end response = @excon.request(params, &block) if parser body.finish response.body = parser.response end response end |
#reset ⇒ Object
31 32 33 |
# File 'lib/fog/core/connection.rb', line 31 def reset @excon.reset end |