title: Can't get recursive method to work
body: <p>I have the following method:</p>
  
  <pre><code>def all(response = nil, options = {}, data = [])
    response ||= get(resource_path, options)
    parsed_response = JSON.parse(response.body)
    return bad_response(response) unless response.code == '200'
  
    data += parsed_response['data'].nil? ? [] : parsed_response['data'].map { |obj| new(obj) }
    puts data.count
    if parsed_response.dig('additional_data', 'pagination', 'more_items_in_collection')
  
      options[:start] = parsed_response.dig('additional_data', 'pagination', 'next_start')
      all(nil, options, data) # recursively calls itself, passing cumulated data
    end
    puts data.count # WHY WOULD IT NOT JUST RETURN ONCE, BUT INSTEAD GO DOWN TO INITIAL VALUE?
    data
  end
  </code></pre>
  
  <p>My problem with this method, is that when it's time to exit the method:
   (<code>if parsed_response.dig('additional_data', 'pagination', 'more_items_in_collection')</code> returns <code>false</code> and the last method's line should be fired), it starts to rewind..</p>
  
  <p>The output is:</p>
  
  <pre><code>Pipedrive::Customer.all.count
  100
  200
  300
  400
  500
  600
  700
  800
  900
  1000
  1100
  1200
  1300
  1400
  1500
  1600
  1700
  1800
  1900
  2000
  2100
  2200
  2300
  2400
  2500
  2600
  2700
  2800
  2900
  3000
  3100
  3200
  3300
  3400
  3500
  3600
  3700
  3800
  3900
  3991
  3991
  3900
  3800
  3700
  3600
  3500
  3400
  3300
  3200
  3100
  3000
  2900
  2800
  2700
  2600
  2500
  2400
  2300
  2200
  2100
  2000
  1900
  1800
  1700
  1600
  1500
  1400
  1300
  1200
  1100
  1000
  900
  800
  700
  600
  500
  400
  300
  200
  100
  =&gt; 100
  </code></pre>
  
  <p>This looks insane, but I hope I'm just missing something extremely simple (indeed I am, but what exactly :) ).</p>
  
  <h1>EDIT</h1>
  
  <p>My problem is with the <strong>result of the method</strong>, not with puts itself. I would expect the <code>Pipedrive::Customer.all.count</code> to return <code>3991</code>, but it returns <code>100</code> instead... Any ideas? I already tried to put last line (<code>data</code>) in <code>else</code></p>
  
  <pre><code>  def all(response = nil, options = {}, data = [])
      response ||= get(resource_path, options)
      parsed_response = JSON.parse(response.body)
      return bad_response(response) unless response.code == '200'
  
      data += parsed_response['data'].nil? ? [] : parsed_response['data'].map { |obj| new(obj) }
      if parsed_response.dig('additional_data', 'pagination', 'more_items_in_collection')
  
        options[:start] = parsed_response.dig('additional_data', 'pagination', 'next_start')
        all(nil, options, data)
      else
        data
      end
      data 
    end
  </code></pre>
  
  <p>- it still returns <code>100</code>..</p>