Module: BlizzardApi::Configuration
- Included in:
- BlizzardApi
- Defined in:
- lib/blizzard_api/configuration.rb
Overview
Global configurations
Instance Attribute Summary collapse
-
#app_id ⇒ String
Application ID.
-
#app_secret ⇒ String
Application secret.
-
#cache_access_token ⇒ Boolean
If set to true and cache is enabled the current access token will be cached and recovered from Redis.
-
#mode ⇒ Symbol
Api response mode :regular or :extended.
-
#redis_url ⇒ Object
Redis connection string.
-
#region ⇒ String
Default region.
Class Method Summary collapse
-
.extended(base) ⇒ Object
Initializes some default values for the main module.
Instance Method Summary collapse
-
#configure { ... } ⇒ Object
This method return the singleton instance of the configuration module.
- #use_cache? ⇒ Boolean
Instance Attribute Details
#app_id ⇒ String
Application ID.
11 12 13 |
# File 'lib/blizzard_api/configuration.rb', line 11 def app_id @app_id end |
#app_secret ⇒ String
Application secret.
18 19 20 |
# File 'lib/blizzard_api/configuration.rb', line 18 def app_secret @app_secret end |
#cache_access_token ⇒ Boolean
If set to true and cache is enabled the current access token will be cached and recovered from Redis
42 43 44 |
# File 'lib/blizzard_api/configuration.rb', line 42 def cache_access_token @cache_access_token end |
#mode ⇒ Symbol
Api response mode :regular or :extended.
30 31 32 |
# File 'lib/blizzard_api/configuration.rb', line 30 def mode @mode end |
#redis_url ⇒ Object
Redis connection string. Overrides redis_host, redis_port and redis_database.
36 37 38 |
# File 'lib/blizzard_api/configuration.rb', line 36 def redis_url @redis_url end |
#region ⇒ String
Default region.
24 25 26 |
# File 'lib/blizzard_api/configuration.rb', line 24 def region @region end |
Class Method Details
.extended(base) ⇒ Object
Initializes some default values for the main module
64 65 66 |
# File 'lib/blizzard_api/configuration.rb', line 64 def self.extended(base) base.mode = :regular end |
Instance Method Details
#configure { ... } ⇒ Object
This method return the singleton instance of the configuration module. Use this to initialize the default values and options.
BlizzardApi.configure do |config|
config.app_id = ENV['BNET_APPLICATION_ID']
config.app_secret = ENV['BNET_APPLICATION_SECRET']
config.region = 'us'
config.redis_url = 'redis://localhost:6379/0'
config.cache_access_token = true
end
58 59 60 |
# File 'lib/blizzard_api/configuration.rb', line 58 def configure yield self end |
#use_cache? ⇒ Boolean
68 69 70 |
# File 'lib/blizzard_api/configuration.rb', line 68 def use_cache? @use_cache ||= !redis_url.nil? end |