Module: SettingAccessors::Helpers
Defined Under Namespace
Classes: Error, NestedHashKeyNotFoundException
Instance Method Summary
collapse
Instance Method Details
#ensure_nested_hash!(hash, *keys) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/setting_accessors/helpers.rb', line 8
def ensure_nested_hash!(hash, *keys)
h = hash
keys.each do |key|
h[key] ||= {}
h = h[key]
end
end
|
#lookup_nested_hash(hash, *keys) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/setting_accessors/helpers.rb', line 16
def lookup_nested_hash(hash, *keys)
fail NestedHashKeyNotFoundException if hash.nil?
h = hash
keys.each do |key|
fail NestedHashKeyNotFoundException unless h.key?(key)
h = h[key]
end
h
end
|