Class: CalendarApi::Server
- Inherits:
-
Object
- Object
- CalendarApi::Server
- Defined in:
- lib/calendar_api/configuration.rb
Overview
An enum for API servers.
Constant Summary collapse
- SERVER =
[ DEFAULT = 'default'.freeze, AUTH_SERVER = 'auth server'.freeze, ACCESS_TOKEN_SERVER = 'access token server'.freeze ].freeze
Class Method Summary collapse
-
.from_value(value, default_value = DEFAULT) ⇒ Object
Converts a string or symbol into a valid Server constant.
Class Method Details
.from_value(value, default_value = DEFAULT) ⇒ Object
Converts a string or symbol into a valid Server constant.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/calendar_api/configuration.rb', line 31 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 'auth_server' then AUTH_SERVER when 'access_token_server' then ACCESS_TOKEN_SERVER else warn "[Server] Unknown server '#{value}', falling back to #{default_value} " default_value end end |