Method: Dnsimple::Client::ClientService#paginate
- Defined in:
- lib/dnsimple/client/clients.rb
#paginate(method, *args) ⇒ Dnsimple::CollectionResponse
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper that loops over a paginated response and returns all the records in the collection.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/dnsimple/client/clients.rb', line 92 def paginate(method, *args) current_page = 0 total_pages = nil collection = [] = args.pop response = nil begin current_page += 1 query = Extra.deep_merge(, query: { page: current_page, per_page: 100 }) response = send(method, *(args + [query])) total_pages ||= response.total_pages collection.concat(response.data) end while current_page < total_pages CollectionResponse.new(response.http_response, collection) end |