Class: PaysecureApiDocumentationLive::Server
- Inherits:
-
Object
- Object
- PaysecureApiDocumentationLive::Server
- Defined in:
- lib/paysecure_api_documentation_live/configuration.rb
Overview
An enum for API servers.
Constant Summary collapse
- SERVER =
[ SERVER_1 = 'Server 1'.freeze, SERVER_2 = 'Server 2'.freeze, SERVER_3 = 'Server 3'.freeze, SERVER_4 = 'Server 4'.freeze ].freeze
Class Method Summary collapse
-
.from_value(value, default_value = SERVER_1) ⇒ Object
Converts a string or symbol into a valid Server constant.
Class Method Details
.from_value(value, default_value = SERVER_1) ⇒ 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 45 |
# File 'lib/paysecure_api_documentation_live/configuration.rb', line 31 def self.from_value(value, default_value = SERVER_1) return default_value if value.nil? str = value.to_s.strip.downcase case str when 'server_1' then SERVER_1 when 'server_2' then SERVER_2 when 'server_3' then SERVER_3 when 'server_4' then SERVER_4 else warn "[Server] Unknown server '#{value}', falling back to #{default_value} " default_value end end |