Class: GrapeClient::Connection
- Inherits:
-
Object
- Object
- GrapeClient::Connection
- Defined in:
- lib/grape_client/connection.rb
Defined Under Namespace
Classes: InvalidEntity, Unauthorized, UndefinedMethod, UnknownError
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#initialize(user, password) ⇒ Connection
constructor
A new instance of Connection.
- #request(method, url, params = {}) ⇒ Object
Constructor Details
#initialize(user, password) ⇒ Connection
Returns a new instance of Connection.
12 13 14 15 |
# File 'lib/grape_client/connection.rb', line 12 def initialize(user, password) @user = user @password = password end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
10 11 12 |
# File 'lib/grape_client/connection.rb', line 10 def headers @headers end |
Instance Method Details
#request(method, url, params = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/grape_client/connection.rb', line 17 def request(method, url, params = {}) uri = prepare_uri(method, url, params) req = prepare_request(method, uri, params) res = Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(req) end @headers = res.to_hash validate_response res end |