Class: GoogleMapsPlatform::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/google_maps_platform/configuration.rb

Overview

An enum for SDK environments.

Constant Summary collapse

ENVIRONMENT =
[
  PRODUCTION = 'production'.freeze,
  ENVIRONMENT2 = 'environment2'.freeze,
  ENVIRONMENT3 = 'environment3'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = PRODUCTION) ⇒ Object

Converts a string or symbol into a valid Environment constant.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/google_maps_platform/configuration.rb', line 16

def self.from_value(value, default_value = PRODUCTION)
  return default_value if value.nil?

  str = value.to_s.strip.downcase
  case str
  when 'production' then PRODUCTION
  when 'environment2' then ENVIRONMENT2
  when 'environment3' then ENVIRONMENT3

  else
    warn "[Environment] Unknown environment '#{value}', falling back to #{default_value} "
    default_value
  end
end