Hash.class_eval do
# TODO: unit test this
def find_and_replace( x, y )
self.dup.find_and_replace! x, y
end
def find_and_replace!( x, y )
self.each_pair do |k,v|
if v.is_a?(Hash)
v.find_and_replace! x, y
else
if x.is_a?(Regexp) && v.is_a?(String)
v.gsub!( x, y )
else
v = y if v == x
end
self[k] = v
end
end
end
end

