Class: ShellDataReportingApIs::Server

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

Overview

An enum for API servers.

Constant Summary collapse

SERVER =
[
  OAUTH_SERVER = 'OAuth Server'.freeze,
  SHELL = 'Shell'.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.



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

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

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