Class: EnvParameterStore::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/env_parameter_store.rb

Instance Method Summary collapse

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_namesObject



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