Class: ConfigurationService::Factory::EnvironmentContext::EnvDict
- Inherits:
-
Hash
- Object
- Hash
- ConfigurationService::Factory::EnvironmentContext::EnvDict
- Defined in:
- lib/configuration_service/factory/environment_context/env_dict.rb
Instance Method Summary collapse
-
#initialize(sources, *path) ⇒ EnvDict
constructor
A new instance of EnvDict.
- #scrub! ⇒ Object
- #subslice(key) ⇒ Object
- #subslice!(key) ⇒ Object
Constructor Details
#initialize(sources, *path) ⇒ EnvDict
Returns a new instance of EnvDict.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/configuration_service/factory/environment_context/env_dict.rb', line 9 def initialize(sources, *path) @sources = sources.is_a?(Array) ? sources : [ sources ] @env = @sources.inject { |m, e| m.merge(e) } @path = build_path(*path) env_keys.each do |k| self.store(symbolic_key(k), @env[k]) end self.default_proc = envdict_default_proc end |
Instance Method Details
#scrub! ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/configuration_service/factory/environment_context/env_dict.rb', line 32 def scrub! @path or raise RuntimeError, "refusing to scrub without path" scrub_env! scrub_slices! scrub_self! @scrubbed = true end |
#subslice(key) ⇒ Object
21 22 23 24 25 |
# File 'lib/configuration_service/factory/environment_context/env_dict.rb', line 21 def subslice(key) EnvDict.new(@env, @path, key).tap do |s| (@slices ||= []) << s end end |
#subslice!(key) ⇒ Object
27 28 29 30 |
# File 'lib/configuration_service/factory/environment_context/env_dict.rb', line 27 def subslice!(key) delete_keys_prefixed_with!(key) subslice(key) end |