Class: ScalrApiV2::Config
- Inherits:
-
Object
- Object
- ScalrApiV2::Config
- Defined in:
- lib/scalr_api_v2/config.rb
Overview
config class
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #mode_path(env_id) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
4 |
# File 'lib/scalr_api_v2/config.rb', line 4 def initialize; end |
Instance Method Details
#config ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/scalr_api_v2/config.rb', line 15 def config config = {} if ENV['SCALR_URL'].nil? || ENV['SCALR_KEY_ID'].nil? || ENV['SCALR_KEY_SECRET'].nil? config['error'] = 'Missing Environment variables, please configure SCALR_URL, SCALR_KEY_ID, SCALR_KEY_SECRET' raise 'Missing Environment variables, please configure SCALR_URL, SCALR_KEY_ID, SCALR_KEY_SECRET' else config['url'] = ENV['SCALR_URL'] config['key_id'] = ENV['SCALR_KEY_ID'] config['key_secret'] = ENV['SCALR_KEY_SECRET'] config['env_id'] = ENV['SCALR_ENV_ID'].nil? ? nil : ENV['SCALR_ENV_ID'] config['mode_path'] = mode_path(config['env_id']) end return config end |
#mode_path(env_id) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/scalr_api_v2/config.rb', line 6 def mode_path(env_id) mode = if env_id.nil? 'account' else Integer(env_id) >= 0 ? 'user' : 'account' end return mode == 'account' ? 'account' : "user/#{env_id}" end |