Class: HttpApiClient::ConnectionFactory
- Inherits:
-
Object
- Object
- HttpApiClient::ConnectionFactory
- Defined in:
- lib/http_api_client/connection_factory.rb
Constant Summary collapse
- OSX_CERT_PATH =
'/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt'
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(config) ⇒ ConnectionFactory
constructor
A new instance of ConnectionFactory.
Constructor Details
#initialize(config) ⇒ ConnectionFactory
Returns a new instance of ConnectionFactory.
10 11 12 |
# File 'lib/http_api_client/connection_factory.rb', line 10 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/http_api_client/connection_factory.rb', line 8 def config @config end |
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/http_api_client/connection_factory.rb', line 14 def create Faraday.new() do |connection| connection.port = config.port if config.port connection.request :url_encoded # form-encode POST params connection.adapter :net_http # connection.use :http_cache # connection.response :logger if config.http_basic_username connection.basic_auth(config.http_basic_username, config.http_basic_password) end end end |