def flatten(hash)
        hash.each_with_object({}) do |(key, value), h|
          if value.instance_of?(Hash)
            value.map do |k, v|
              # We could add recursion here if we ever had more than 2 levels
              h["#{key}.#{k}"] = v
            end
          else
            h[key] = value
          end
        end
      end
def flatten(hash)
        hash.each_with_object({}) do |(key, value), h|
          if value.instance_of?(Hash)
            value.map do |k, v|
              # We could add recursion here if we ever had more than 2 levels
              h["#{key}.#{k}"] = v
            end
          else
            h[key] = value
          end
        end
      end
Given a deeply nested hash, return a single hash