Class: Spreedly::Connection
- Inherits:
-
Object
- Object
- Spreedly::Connection
- Defined in:
- lib/spreedly/connection.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
Instance Method Summary collapse
-
#initialize(endpoint) ⇒ Connection
constructor
A new instance of Connection.
- #request(method, body, headers = {}) ⇒ Object
Constructor Details
#initialize(endpoint) ⇒ Connection
Returns a new instance of Connection.
9 10 11 |
# File 'lib/spreedly/connection.rb', line 9 def initialize(endpoint) @endpoint = URI.parse(endpoint) end |
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
7 8 9 |
# File 'lib/spreedly/connection.rb', line 7 def endpoint @endpoint end |
Instance Method Details
#request(method, body, headers = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spreedly/connection.rb', line 13 def request(method, body, headers = {}) case method when :get http.get(endpoint.request_uri, headers) when :post http.post(endpoint.request_uri, body, headers) when :put http.put(endpoint.request_uri, body, headers) when :delete http.delete(endpoint.request_uri, headers) else raise ArgumentError, "Unsupported request method #{method.to_s.upcase}" end end |