Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Made this changes, as @aleccarper suggested [here](davidbiehl#6 (comment))
I was encountering those issue quite often while using this gem on my production app, @davidbiehl also asked for pull request, so I made it
  • Loading branch information
Nkadze authored Aug 4, 2018
1 parent 7c9796e commit 6e82dbc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/ecwid_api/paged_ecwid_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ def initialize(client, path, params = {}, &block)
response = client.get(path, params)

@paged_enumerator = PagedEnumerator.new(response) do |response, yielder|
response.body["items"].each do |item|
yielder << block.call(item)
end


count, offset, total = %w(count offset total).map do |i|
response.body[i].to_i
end

if count > 0
response.body["items"].each do |item|
yielder << block.call(item)
end
end

if count == 0 || count + offset >= total
false
Expand All @@ -52,4 +55,4 @@ def initialize(client, path, params = {}, &block)
end
end
end
end
end

0 comments on commit 6e82dbc

Please sign in to comment.