Module: BlizzardApi::Configuration

Included in:
BlizzardApi
Defined in:
lib/blizzard_api/configuration.rb

Overview

Global configurations

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_idString

Application ID.

Returns:

  • (String)

    Application ID

See Also:



11
12
13
# File 'lib/blizzard_api/configuration.rb', line 11

def app_id
  @app_id
end

#app_secretString

Application secret.

Returns:

  • (String)

    Application secret

See Also:



18
19
20
# File 'lib/blizzard_api/configuration.rb', line 18

def app_secret
  @app_secret
end

#cache_access_tokenBoolean

If set to true and cache is enabled the current access token will be cached and recovered from Redis

Returns:

  • (Boolean)

    Access token.



42
43
44
# File 'lib/blizzard_api/configuration.rb', line 42

def cache_access_token
  @cache_access_token
end

#modeSymbol

Api response mode :regular or :extended.

Returns:

  • (Symbol)

    Default API response mode



30
31
32
# File 'lib/blizzard_api/configuration.rb', line 30

def mode
  @mode
end

#redis_urlObject

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

#regionString

Default region.

Returns:

  • (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

Yields:

  • self



58
59
60
# File 'lib/blizzard_api/configuration.rb', line 58

def configure
  yield self
end

#use_cache?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/blizzard_api/configuration.rb', line 68

def use_cache?
  @use_cache ||= !redis_url.nil?
end