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,
lib/environment_config/types/integer_list.rb
Defined Under Namespace
Classes: Boolean, Integer, IntegerList, Json, String, StringList, Symbol, TypeError, Yaml
Constant Summary
collapse
- ALL =
[
::EnvironmentConfig::Types::Boolean,
::EnvironmentConfig::Types::Integer,
::EnvironmentConfig::Types::IntegerList,
::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
28
29
30
31
32
33
34
35
36
|
# File 'lib/environment_config/types.rb', line 28
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
42
43
44
|
# File 'lib/environment_config/types.rb', line 42
def known_type?(type_name)
type_map.key?(type_name.to_sym)
end
|
.type_names ⇒ Object
38
39
40
|
# File 'lib/environment_config/types.rb', line 38
def type_names
type_map.keys
end
|