Class: VehiclesDB::Configuration
- Inherits:
-
Object
- Object
- VehiclesDB::Configuration
- Defined in:
- lib/vehiclesdb/configuration.rb
Overview
Global configuration. Sensible defaults; the API key is picked up from ENV automatically, so the common case needs no setup.
VehiclesDB.configure do |config|
config.api_key = "vdb_live_..."
end
Instance Attribute Summary collapse
-
#api_base_url ⇒ Object
Base URL of the API.
-
#api_key ⇒ Object
Your VehiclesDB API key.
-
#timeout ⇒ Object
Request timeout in seconds.
-
#user_agent ⇒ Object
Sent as the User-Agent header so VehiclesDB can see SDK usage.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 26 27 28 |
# File 'lib/vehiclesdb/configuration.rb', line 23 def initialize @api_key = ENV.fetch("VEHICLESDB_API_KEY", nil) @api_base_url = "https://api.vehiclesdb.com" @timeout = 5 @user_agent = "vehiclesdb-ruby/#{VehiclesDB::VERSION}" end |
Instance Attribute Details
#api_base_url ⇒ Object
Base URL of the API. Overridable for self-hosting / staging / testing.
15 16 17 |
# File 'lib/vehiclesdb/configuration.rb', line 15 def api_base_url @api_base_url end |
#api_key ⇒ Object
Your VehiclesDB API key. Defaults to ENV.
12 13 14 |
# File 'lib/vehiclesdb/configuration.rb', line 12 def api_key @api_key end |
#timeout ⇒ Object
Request timeout in seconds.
18 19 20 |
# File 'lib/vehiclesdb/configuration.rb', line 18 def timeout @timeout end |
#user_agent ⇒ Object
Sent as the User-Agent header so VehiclesDB can see SDK usage.
21 22 23 |
# File 'lib/vehiclesdb/configuration.rb', line 21 def user_agent @user_agent end |