Sha256: f36b650772246c3a826c9dfcd27c9974531f899d6a1596bce856d9f32bf34770
Contents?: true
Size: 570 Bytes
Versions: 3
Compression:
Stored size: 570 Bytes
Contents
module TFG module Support class DeepHashAccessor def initialize(hash) self.hash = hash end def [](*keys) head, *tail = keys if tail.empty? hash[head] else hash[head].deep[*tail] if hash[head] end end def []=(*keys, value) head, *tail = keys if tail.empty? hash[head] = value else hash[head] ||= Hash.new hash[head].deep[*tail] = value end end private attr_accessor :hash end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tfg_support-1.1.1 | lib/tfg/support/deep_hash_accessor.rb |
tfg_support-1.0.1 | lib/tfg/support/deep_hash_accessor.rb |
tfg_support-1.0.0 | lib/tfg/support/deep_hash_accessor.rb |