class Atum::Core::Paginator
Constants
- LIMIT_INCREMENT
Public Class Methods
new(request, initial_response, options)
click to toggle source
# File lib/atum/core/paginator.rb, line 6 def initialize(request, initial_response, options) @request = request @options = options @initial_response = initial_response end
Public Instance Methods
enumerator()
click to toggle source
# File lib/atum/core/paginator.rb, line 12 def enumerator response = @initial_response Enumerator.new do |yielder| loop do items = @request.unenvelope(response.body) items.each { |item| yielder << item } break if items.count < response.limit new_options = @options.dup new_options[:query] = @options.fetch(:query, {}).merge( after: response.meta['cursors']['after'], limit: response.limit + LIMIT_INCREMENT) response = @request.make_request(new_options) end end.lazy end