Class: CartoDB::Api::Configuration
- Inherits:
-
Object
- Object
- CartoDB::Api::Configuration
- Defined in:
- lib/cartodb/api/configuration.rb
Constant Summary collapse
- PROTOCOL =
'https'- DOMAIN =
'cartodb.com'- TIMEOUT =
30- VERSION =
1
Instance Attribute Summary collapse
-
#account ⇒ Object
Public: Gets or sets the CartoDB account from which all requests are going to be made from.
-
#api_key ⇒ Object
Public: Gets or sets the CartoDB API key that will be used for authentication.
- #domain ⇒ Object
- #protocol ⇒ Object
- #timeout ⇒ Object
- #version ⇒ Object
Instance Method Summary collapse
- #assert_attr(attr, attr_name) ⇒ Object
- #assert_configuration ⇒ Object
- #assert_in_options(attr, options, attr_name) ⇒ Object
- #base_url ⇒ Object
Instance Attribute Details
#account ⇒ Object
Public: Gets or sets the CartoDB account from which all requests are going to be made from.
11 12 13 |
# File 'lib/cartodb/api/configuration.rb', line 11 def account @account end |
#api_key ⇒ Object
Public: Gets or sets the CartoDB API key that will be used for authentication.
14 15 16 |
# File 'lib/cartodb/api/configuration.rb', line 14 def api_key @api_key end |
#domain ⇒ Object
32 33 34 |
# File 'lib/cartodb/api/configuration.rb', line 32 def domain @domain || DOMAIN end |
#protocol ⇒ Object
28 29 30 |
# File 'lib/cartodb/api/configuration.rb', line 28 def protocol @protocol || PROTOCOL end |
#timeout ⇒ Object
40 41 42 |
# File 'lib/cartodb/api/configuration.rb', line 40 def timeout @timeout || TIMEOUT end |
#version ⇒ Object
36 37 38 |
# File 'lib/cartodb/api/configuration.rb', line 36 def version @version || VERSION end |
Instance Method Details
#assert_attr(attr, attr_name) ⇒ Object
57 58 59 |
# File 'lib/cartodb/api/configuration.rb', line 57 def assert_attr(attr, attr_name) raise InvalidConfiguration.new("#{attr_name} should not be nil.") if attr.nil? end |
#assert_configuration ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/cartodb/api/configuration.rb', line 49 def assert_configuration assert_attr(account, 'Account') assert_attr(api_key, 'API key') (protocol, %w{http https}, 'Protocol') assert_attr(domain, 'Domain') assert_attr(version, 'API version number') end |
#assert_in_options(attr, options, attr_name) ⇒ Object
61 62 63 64 65 |
# File 'lib/cartodb/api/configuration.rb', line 61 def (attr, , attr_name) assert_attr(attr, attr_name) = "#{attr_name} is not a valid option. Should be any of: #{options.join(', ')}" raise InvalidConfiguration.new() unless .include? attr end |
#base_url ⇒ Object
44 45 46 47 |
# File 'lib/cartodb/api/configuration.rb', line 44 def base_url assert_configuration "#{protocol}://#{account}.#{domain}/api/" end |