Class: LoyaltyApIs::Server

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

Overview

An enum for API servers.

Constant Summary collapse

SERVER =
[
  OAUTH_SERVER = 'OAuth Server'.freeze,
  SHELL = 'Shell'.freeze,
  SHELL1 = 'Shell1'.freeze,
  SHELL2 = 'Shell2'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = OAUTH_SERVER) ⇒ Object

Converts a string or symbol into a valid Server constant.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/loyalty_ap_is/configuration.rb', line 42

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

  str = value.to_s.strip.downcase
  case str
  when 'oauth_server' then OAUTH_SERVER
  when 'shell' then SHELL
  when 'shell1' then SHELL1
  when 'shell2' then SHELL2

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