Class: Rester::Client::Adapters::HttpAdapter::Connection
- Inherits:
-
Object
- Object
- Rester::Client::Adapters::HttpAdapter::Connection
- Defined in:
- lib/rester/client/adapters/http_adapter/connection.rb
Constant Summary collapse
- DEFAULT_DATA_HEADERS =
{ "Content-Type".freeze => "application/x-www-form-urlencoded".freeze }.freeze
Instance Attribute Summary collapse
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, opts = {}) ⇒ Connection
constructor
A new instance of Connection.
- #request(verb, path, params = {}) ⇒ Object
Constructor Details
#initialize(url, opts = {}) ⇒ Connection
Returns a new instance of Connection.
15 16 17 18 19 |
# File 'lib/rester/client/adapters/http_adapter/connection.rb', line 15 def initialize(url, opts={}) @url = url.is_a?(String) ? URI(url) : url @url.path = @url.path[0..-2] if @url.path[-1] == '/' @timeout = opts[:timeout] end |
Instance Attribute Details
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
13 14 15 |
# File 'lib/rester/client/adapters/http_adapter/connection.rb', line 13 def timeout @timeout end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
12 13 14 |
# File 'lib/rester/client/adapters/http_adapter/connection.rb', line 12 def url @url end |
Instance Method Details
#request(verb, path, params = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/rester/client/adapters/http_adapter/connection.rb', line 21 def request(verb, path, params={}) _request( verb, _path(path, params[:query]), _headers(verb, params[:headers]), params[:data] ) end |