Class: Vertebrae::Connection
- Inherits:
-
Object
- Object
- Vertebrae::Connection
- Includes:
- Authorization, Constants
- Defined in:
- lib/vertebrae/connection.rb
Constant Summary collapse
- ALLOWED_OPTIONS =
[ :headers, :url, :params, :request, :ssl ].freeze
Constants included from Constants
Vertebrae::Constants::ACCEPT, Vertebrae::Constants::ACCEPT_CHARSET, Vertebrae::Constants::CACHE_CONTROL, Vertebrae::Constants::CONTENT_LENGTH, Vertebrae::Constants::CONTENT_TYPE, Vertebrae::Constants::DATE, Vertebrae::Constants::ETAG, Vertebrae::Constants::LOCATION, Vertebrae::Constants::RATELIMIT_LIMIT, Vertebrae::Constants::RATELIMIT_REMAINING, Vertebrae::Constants::SERVER, Vertebrae::Constants::USER_AGENT
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#faraday_connection ⇒ Object
Returns the value of attribute faraday_connection.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#connection ⇒ Object
Returns a Faraday::Connection object.
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
Methods included from Authorization
#authenticated?, #authentication, #basic_auth, #password?, #username?
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
26 27 28 29 30 |
# File 'lib/vertebrae/connection.rb', line 26 def initialize() @options = @configuration = Vertebrae::Configuration.new() @stack = nil end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
15 16 17 |
# File 'lib/vertebrae/connection.rb', line 15 def configuration @configuration end |
#faraday_connection ⇒ Object
Returns the value of attribute faraday_connection.
16 17 18 |
# File 'lib/vertebrae/connection.rb', line 16 def faraday_connection @faraday_connection end |
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/vertebrae/connection.rb', line 14 def @options end |
Instance Method Details
#connection ⇒ Object
Returns a Faraday::Connection object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vertebrae/connection.rb', line 39 def connection self.faraday_connection ||= Faraday.new(configuration.) do |f| if configuration.authenticated? f.request :authorization, :basic, configuration.username, configuration.password end f.request :multipart f.request :url_encoded unless [:raw] f.response :mashify f.response :json end f.response :raise_error f.adapter configuration.adapter end end |