Class: EnvParameterStore::Config
- Inherits:
-
Object
- Object
- EnvParameterStore::Config
- Defined in:
- lib/env_parameter_store.rb
Instance Method Summary collapse
-
#initialize(config_json) ⇒ Config
constructor
A new instance of Config.
- #parameter_names ⇒ Object
- #to_name(qualified_name) ⇒ Object
Constructor Details
#initialize(config_json) ⇒ Config
Returns a new instance of Config.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/env_parameter_store.rb', line 78 def initialize(config_json) unless config_json.key?('prefix') \ && config_json.key?('parameters') \ && config_json.fetch('prefix').is_a?(String) \ && config_json.fetch('parameters').is_a?(Array) \ && config_json.fetch('parameters').all? { |key| key.is_a?(String) } raise EnvParameterStore::InvalidJSONError.new end prefix = config_json.fetch('prefix') @qualified_names_to_names = config_json.fetch('parameters').each_with_object({}) do |key, table| table[prefix + key] = key end end |
Instance Method Details
#parameter_names ⇒ Object
97 98 99 |
# File 'lib/env_parameter_store.rb', line 97 def parameter_names @qualified_names_to_names.keys end |
#to_name(qualified_name) ⇒ Object
93 94 95 |
# File 'lib/env_parameter_store.rb', line 93 def to_name(qualified_name) @qualified_names_to_names.fetch(qualified_name) end |