Class: SplititWebApiV4::Server

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

Overview

An enum for API servers.

Constant Summary collapse

SERVER =
[
  DEFAULT = 'default'.freeze,
  ACCESS_TOKEN_SERVER = 'access token server'.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.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/splitit_web_api_v4/configuration.rb', line 38

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 'access_token_server' then ACCESS_TOKEN_SERVER

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