Class: MistApi::Environment
- Inherits:
-
Object
- Object
- MistApi::Environment
- Defined in:
- lib/mist_api/configuration.rb
Overview
An enum for SDK environments.
Constant Summary collapse
- ENVIRONMENT =
[ MIST_GLOBAL_01 = 'Mist Global 01'.freeze, MIST_GLOBAL_02 = 'Mist Global 02'.freeze, MIST_GLOBAL_03 = 'Mist Global 03'.freeze, MIST_GLOBAL_04 = 'Mist Global 04'.freeze, MIST_GLOBAL_05 = 'Mist Global 05'.freeze, MIST_EMEA_01 = 'Mist EMEA 01'.freeze, MIST_EMEA_02 = 'Mist EMEA 02'.freeze, MIST_EMEA_03 = 'Mist EMEA 03'.freeze, MIST_EMEA_04 = 'Mist EMEA 04'.freeze, MIST_APAC_01 = 'Mist APAC 01'.freeze, MIST_APAC_02 = 'Mist APAC 02'.freeze, MIST_APAC_03 = 'Mist APAC 03'.freeze ].freeze
Class Method Summary collapse
-
.from_value(value, default_value = MIST_GLOBAL_01) ⇒ Object
Converts a string or symbol into a valid Environment constant.
Class Method Details
.from_value(value, default_value = MIST_GLOBAL_01) ⇒ Object
Converts a string or symbol into a valid Environment constant.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mist_api/configuration.rb', line 25 def self.from_value(value, default_value = MIST_GLOBAL_01) return default_value if value.nil? str = value.to_s.strip.downcase case str when 'mist_global_01' then MIST_GLOBAL_01 when 'mist_global_02' then MIST_GLOBAL_02 when 'mist_global_03' then MIST_GLOBAL_03 when 'mist_global_04' then MIST_GLOBAL_04 when 'mist_global_05' then MIST_GLOBAL_05 when 'mist_emea_01' then MIST_EMEA_01 when 'mist_emea_02' then MIST_EMEA_02 when 'mist_emea_03' then MIST_EMEA_03 when 'mist_emea_04' then MIST_EMEA_04 when 'mist_apac_01' then MIST_APAC_01 when 'mist_apac_02' then MIST_APAC_02 when 'mist_apac_03' then MIST_APAC_03 else warn "[Environment] Unknown environment '#{value}', falling back to #{default_value} " default_value end end |