#459 - Fix iteration for genomics API which only has 1 item per page

This commit is contained in:
Steve Bazyl committed 2016-08-31 13:26:24 -07:00
1 parent 8735e62c70
commit 70596d26f6
2 files changed
+17 -8

No files matched your search

+10 -5
View File
@@ -64,11 +64,16 @@ module Google
loop do
@last_result = @fetch_proc.call(page_token)
items = @last_result.send(@items_field)
for item in items
item_count = item_count + 1
break if @max && item_count > @max
yield item
end unless items.nil?
if items.kind_of?(Array)
for item in items
item_count = item_count + 1
break if @max && item_count > @max
yield item
end
elsif items
# yield singular non-nil items (for genomics API)
yield items
end
break if @max && item_count >= @max
break if @last_result.next_page_token.nil? || @last_result.next_page_token == page_token
page_token = @last_result.next_page_token