Module: EnvironmentConfig::Types
- Defined in:
- lib/environment_config/types.rb,
lib/environment_config/types/json.rb,
lib/environment_config/types/yaml.rb,
lib/environment_config/types/string.rb,
lib/environment_config/types/symbol.rb,
lib/environment_config/types/boolean.rb,
lib/environment_config/types/integer.rb,
lib/environment_config/types/type_error.rb,
lib/environment_config/types/string_list.rb
Defined Under Namespace
Classes: Boolean, Integer, Json, String, StringList, Symbol, TypeError, Yaml
Constant Summary
collapse
- ALL =
[
::EnvironmentConfig::Types::Boolean,
::EnvironmentConfig::Types::Integer,
::EnvironmentConfig::Types::Json,
::EnvironmentConfig::Types::String,
::EnvironmentConfig::Types::StringList,
::EnvironmentConfig::Types::Symbol,
::EnvironmentConfig::Types::Yaml
].freeze
Class Method Summary
collapse
Class Method Details
.convert(type_name, key, value) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/environment_config/types.rb', line 26
def convert(type_name, key, value)
type = type_map.fetch(type_name.to_sym)
type.convert(value)
rescue Types::TypeError => e
raise ArgumentError,
"Environment variable #{key} could not be read as #{type_name}." \
" Expected: #{e.expected_message}" \
" Got: #{e.value}"
end
|
.known_type?(type_name) ⇒ Boolean
40
41
42
|
# File 'lib/environment_config/types.rb', line 40
def known_type?(type_name)
type_map.key?(type_name.to_sym)
end
|
.type_names ⇒ Object
36
37
38
|
# File 'lib/environment_config/types.rb', line 36
def type_names
type_map.keys
end
|