Method: Clever::Paginator#fetch
- Defined in:
- lib/clever/paginator.rb
#fetch ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/clever/paginator.rb', line 17 def fetch Enumerator.new do |yielder| loop do response = request(@next_path || @path) body = response.body fail "Failed to fetch #{@path}" unless response.success? body.each { |item| add_record(yielder, item) } if body.any? @next_path = response.next_uri fail StopIteration unless @next_path end end.lazy end |