Class: Touringplans::Connection
- Inherits:
-
Object
- Object
- Touringplans::Connection
- Includes:
- HTTParty
- Defined in:
- lib/touringplans.rb
Overview
deals solely with how to create access to the resource, the lock of “lock & key”
Constant Summary collapse
- DEFAULT_API_VERSION =
currently Touring Plans has no verision in its API
"1"
- DEFAULT_BASE_URI =
"https://touringplans.com/"
- DEFAULT_QUERY =
do not freeze DEFAULT_QUERY
{}
Instance Method Summary collapse
- #get(relative_path, query = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #query(params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
96 97 98 99 100 |
# File 'lib/touringplans.rb', line 96 def initialize( = {}) @api_version = .fetch(:api_version, DEFAULT_API_VERSION) @query = .fetch(:query, DEFAULT_QUERY) @connection = self.class end |
Instance Method Details
#get(relative_path, query = {}) ⇒ Object
106 107 108 109 |
# File 'lib/touringplans.rb', line 106 def get(relative_path, query = {}) # relative_path = add_api_version(relative_path) connection.get relative_path, query: @query.merge(query) end |
#query(params = {}) ⇒ Object
102 103 104 |
# File 'lib/touringplans.rb', line 102 def query(params = {}) @query.update(params) end |