Class: Swrve::Configuration
- Inherits:
-
Object
- Object
- Swrve::Configuration
- Defined in:
- lib/swrve/configuration.rb
Constant Summary collapse
- DEFAULT_API_ENDPOINT =
'api.swrve.com'- DEFAULT_ABTEST_ENDPOINT =
'abtest.swrve.com'
Instance Attribute Summary collapse
-
#ab_test_url ⇒ Object
Returns the value of attribute ab_test_url.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#app_version ⇒ Object
Returns the value of attribute app_version.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#game_id ⇒ Object
Returns the value of attribute game_id.
-
#http_adapter ⇒ Object
Returns the value of attribute http_adapter.
-
#load_local_resources ⇒ Object
Returns the value of attribute load_local_resources.
-
#local_resource_path ⇒ Object
Returns the value of attribute local_resource_path.
-
#resource_timeout ⇒ Object
Returns the value of attribute resource_timeout.
Instance Method Summary collapse
- #build_endpoints ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 |
# File 'lib/swrve/configuration.rb', line 10 def initialize @app_version = '0.0' @http_adapter = Faraday.default_adapter @api_version = 1 @resource_timeout = 4 end |
Instance Attribute Details
#ab_test_url ⇒ Object
Returns the value of attribute ab_test_url.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def ab_test_url @ab_test_url end |
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def api_key @api_key end |
#api_url ⇒ Object
Returns the value of attribute api_url.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def api_url @api_url end |
#api_version ⇒ Object
Returns the value of attribute api_version.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def api_version @api_version end |
#app_version ⇒ Object
Returns the value of attribute app_version.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def app_version @app_version end |
#debug ⇒ Object
Returns the value of attribute debug.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def debug @debug end |
#game_id ⇒ Object
Returns the value of attribute game_id.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def game_id @game_id end |
#http_adapter ⇒ Object
Returns the value of attribute http_adapter.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def http_adapter @http_adapter end |
#load_local_resources ⇒ Object
Returns the value of attribute load_local_resources.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def load_local_resources @load_local_resources end |
#local_resource_path ⇒ Object
Returns the value of attribute local_resource_path.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def local_resource_path @local_resource_path end |
#resource_timeout ⇒ Object
Returns the value of attribute resource_timeout.
5 6 7 |
# File 'lib/swrve/configuration.rb', line 5 def resource_timeout @resource_timeout end |
Instance Method Details
#build_endpoints ⇒ Object
17 18 19 20 21 |
# File 'lib/swrve/configuration.rb', line 17 def build_endpoints return if @api_url && @ab_test_url @api_url, @ab_test_url = [ "https://#{game_id}.#{DEFAULT_API_ENDPOINT}", "https://#{game_id}.#{DEFAULT_ABTEST_ENDPOINT}" ] end |
#validate! ⇒ Object
23 24 25 26 27 28 |
# File 'lib/swrve/configuration.rb', line 23 def validate! [:game_id, :api_key].each do |check_valid| raise ConfigurationError, "#{check_valid} is a required configuration setting" if self.send(check_valid).nil? end warn 'app_version is a highly recommended configuration setting, defaulting to 0.0' if app_version == '0.0' end |