title: Process nested hash to convert all values to strings
body: <p>I have the following code which takes a hash and turns all the <strong>values</strong> in to strings.</p>
  
  <pre><code>def stringify_values obj
    @values ||= obj.clone
  
    obj.each do |k, v|
      if v.is_a?(Hash)
        @values[k] = stringify_values(v)
      else
        @values[k] = v.to_s
      end
    end
  
    return @values
  end
  </code></pre>
  
  <p>So given the following hash:</p>
  
  <pre><code>{
    post: {
      id: 123,
      text: 'foobar',
    }
  }
  </code></pre>
  
  <p>I get following <strong>YAML</strong> output</p>
  
  <pre><code>--- &amp;1
  :post: *1
  :id: '123'
  :text: 'foobar'
  </code></pre>
  
  <p>When I want this output</p>
  
  <pre><code>--- 
  :post: 
    :id: '123'
    :text: 'foobar'
  </code></pre>
  
  <p>It looks like the object has been flattened and then been given a reference to itself, which causes Stack level errors in my specs.</p>
  
  <p>How do I get the desired output?</p>