def map_hash(hash)
      # Copy and modify is more performant than mapping to an array and using
      # to_hash on the result.
      rv = hash.class.new
      hash.each do |k, v|
        new_key, new_value = yield(k, v)
        new_key = hash.denormalize(new_key) if hash.is_a?(NormalizedMap) && new_key == k
        rv[new_key] = new_value
      end
      rv
    end
def map_hash(hash)
      # Copy and modify is more performant than mapping to an array and using
      # to_hash on the result.
      rv = hash.class.new
      hash.each do |k, v|
        new_key, new_value = yield(k, v)
        new_key = hash.denormalize(new_key) if hash.is_a?(NormalizedMap) && new_key == k
        rv[new_key] = new_value
      end
      rv
    end
Maps the key-value pairs of a hash according to a block.

 @example
   map_hash({:foo => "bar", :baz => "bang"}) {|k, v| [k.to_s, v.to_sym]}
     #=> {"foo" => :bar, "baz" => :bang}
 @param hash [Hash] The hash to map
 @yield [key, value] A block in which the key-value pairs are transformed
 @yieldparam [key] The hash key
 @yieldparam [value] The hash value
 @yieldreturn [(Object, Object)] The new value for the `[key, value]` pair
 @return [Hash] The mapped hash
 @see #map_keys
 @see #map_vals