Sha256: 48b095b32b8b95d5f43ce952ff7fd0c397dbf3e3044aadfb6a6ab1cc4ee8f2e6
Contents?: true
Size: 669 Bytes
Versions: 2
Compression:
Stored size: 669 Bytes
Contents
class Confrider::Core def initialize @vault = {} end def [](key, default_value = nil) @vault.fetch(key, default_value) end def from_hash(hash) save_hash(nil, hash) end def normalize_keys(*keys) keys.join('.').gsub(/^\./, '') end private def save(key, value) @vault[key] = value end def save_hash(key, hash) if key @vault[key] ||= {} @vault[key].deep_merge!(hash) end hash.each do |inner_key, value| normalized_key = normalize_keys(key, inner_key) if value.is_a? Hash save_hash(normalized_key, value) else save(normalized_key, value) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
confrider-0.1.0 | lib/confrider/core.rb |
confrider-0.0.2 | lib/confrider/core.rb |