Class: WalmartApIs::Server

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

Overview

An enum for API servers.

Constant Summary collapse

SERVER =
[
  DEFAULT = 'default'.freeze,
  DEFAULT1 = 'default1'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = DEFAULT) ⇒ Object

Converts a string or symbol into a valid Server constant.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/walmart_ap_is/configuration.rb', line 40

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

  str = value.to_s.strip.downcase
  case str
  when 'default' then DEFAULT
  when 'default1' then DEFAULT1

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