class TFG::Support::DeepHashAccessor
Attributes
hash[RW]
Public Class Methods
new(hash)
click to toggle source
# File lib/tfg/support/deep_hash_accessor.rb, line 4 def initialize(hash) self.hash = hash end
Public Instance Methods
[](*keys)
click to toggle source
# File lib/tfg/support/deep_hash_accessor.rb, line 8 def [](*keys) head, *tail = keys if tail.empty? hash[head] else hash[head].deep[*tail] if hash[head] end end
[]=(*keys, value)
click to toggle source
# File lib/tfg/support/deep_hash_accessor.rb, line 18 def []=(*keys, value) head, *tail = keys if tail.empty? hash[head] = value else hash[head] ||= Hash.new hash[head].deep[*tail] = value end end