Skip to content

Commit

Permalink
Merge remote-tracking branches 'origin/setparam' and 'origin/paginate…
Browse files Browse the repository at this point in the history
…' into HEAD
  • Loading branch information
notEthan committed Apr 21, 2019
2 parents 482d952 + 98977da commit 9851c18
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/scorpio/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,5 +345,22 @@ def run
ur.raise_on_http_error
ur.response.body_object
end

# todo make a proper iterator interface
# @param next_page [#call] a callable which will take a parameter `page_ur`, which is a {Scorpio::Ur},
# and must result in an Ur representing the next page, which will be yielded to the block.
# @yield [Scorpio::Ur] yields the first page, and each subsequent result of calls to `next_page` until
# that results in nil
# @return [void]
def each_page_ur(next_page: , raise_on_http_error: true)
return to_enum(__method__) unless block_given?
page_ur = run_ur
while page_ur
page_ur.raise_on_http_error if raise_on_http_error
yield page_ur
page_ur = next_page.call(page_ur)
end
nil
end
end
end

0 comments on commit 9851c18

Please sign in to comment.