Skip to content

Commit

Permalink
Merge bda4126 into ba26618
Browse files Browse the repository at this point in the history
  • Loading branch information
ethnext committed Apr 23, 2019
2 parents ba26618 + bda4126 commit 3d2dccd
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 @@ -259,5 +259,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__, next_page: next_page, raise_on_http_error: raise_on_http_error) 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 3d2dccd

Please sign in to comment.