class Zanzou::HashShadow
Public Class Methods
merge(orig_hash, modifications)
click to toggle source
# File lib/zanzou.rb, line 95 def self.merge(orig_hash, modifications) orig_hash.merge(modifications) end
Public Instance Methods
method_missing(name, *args)
click to toggle source
# File lib/zanzou.rb, line 99 def method_missing(name, *args) case name when :[]= handle_setter(args[0], args[1]) when :[] handle_getter(args[0]) else handle_destructive_method_call(name, args) end end
Private Instance Methods
handle_getter(key)
click to toggle source
# File lib/zanzou.rb, line 118 def handle_getter(key) if @modifications.key?(key) return @modifications[key] else return ShadowNode.create(@orig_obj.public_send(key), parent: self, parent_key: key) end end
handle_setter(key, value)
click to toggle source
# File lib/zanzou.rb, line 112 def handle_setter(key, value) modified! @modifications[key] = value return value end