ylecuyer / survey-gizmo-ruby

Gem to use the Survey Gizmo API
MIT License
23 stars 26 forks source link

Iterations aren't reseted after the first usage #104

Open GCorbel opened 5 years ago

GCorbel commented 5 years ago

When we use an iterable, the first time we have the complete list of results but the next time we have only the last page. Here is an example :

responses = SurveyGizmo::API::Survey.first(id: 90063118).responses # => #<Enumerator: ...>
responses.count # => 558
responses.count # => 8

As you can see, the first time we have 558 results but the second time we have only 8. I suppose we always want to have all the results. The simple solution is to store the result with a .to_a but this is just a work around.

WDYT?

jarthod commented 5 years ago

Yep this is not good, it should either stop returning anything and force you to create another iterator or reset and start from scratch (that's a bit more tricky when you iterate one by one, you don't want to go in an infinite loop ^^)