Class: Fog::Core::Connection
- Inherits:
-
Object
- Object
- Fog::Core::Connection
- Defined in:
- lib/fog/core/connection.rb
Overview
Fog::Core::Connection is a generic class to contain a HTTP link to an API.
It is intended to be subclassed by providers who can then add their own modifications such as authentication or response object.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(url, persistent = false, params = {}) ⇒ Connection
constructor
Prepares the connection and sets defaults for any future requests.
-
#request(params, &block) ⇒ Excon::Response
(also: #original_request)
Makes a request using the connection using Excon.
-
#reset ⇒ Object
Closes the connection.
Constructor Details
#initialize(url, persistent = false, params = {}) ⇒ Connection
Prepares the connection and sets defaults for any future requests.
27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/core/connection.rb', line 27 def initialize(url, persistent=false, params={}) unless params.has_key?(:debug_response) params[:debug_response] = true end params[:headers] ||= {} params[:headers]['User-Agent'] ||= "fog/#{Fog::VERSION}" @excon = Excon.new(url, params) @persistent = persistent end |
Instance Method Details
#request(params, &block) ⇒ Excon::Response Also known as: original_request
Makes a request using the connection using Excon
55 56 57 58 |
# File 'lib/fog/core/connection.rb', line 55 def request(params, &block) reset unless @persistent @excon.request(params, &block) end |
#reset ⇒ Object
Closes the connection
68 69 70 |
# File 'lib/fog/core/connection.rb', line 68 def reset @excon.reset end |