Class: ConfigurationService::Factory::EnvironmentContext::EnvDict

Inherits:
Hash
  • Object
show all
Defined in:
lib/configuration_service/factory/environment_context/env_dict.rb

Instance Method Summary collapse

Constructor Details

#initialize(env, *path) ⇒ EnvDict

Returns a new instance of EnvDict.



9
10
11
12
13
14
15
16
17
18
# File 'lib/configuration_service/factory/environment_context/env_dict.rb', line 9

def initialize(env, *path)
  @env = env
  @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



31
32
33
34
35
36
37
38
39
# File 'lib/configuration_service/factory/environment_context/env_dict.rb', line 31

def scrub!
  @path or raise RuntimeError, "refusing to scrub without path"

  scrub_env!
  scrub_slices!
  scrub_self!

  @scrubbed = true
end

#subslice(key) ⇒ Object



20
21
22
23
24
# File 'lib/configuration_service/factory/environment_context/env_dict.rb', line 20

def subslice(key)
  EnvDict.new(@env, @path, key).tap do |s|
    (@slices ||= []) << s
  end
end

#subslice!(key) ⇒ Object



26
27
28
29
# File 'lib/configuration_service/factory/environment_context/env_dict.rb', line 26

def subslice!(key)
  delete_keys_prefixed_with!(key)
  subslice(key)
end