Module: Clientele::Resource::Pagination::Iterator
- Defined in:
- lib/clientele/resource/pagination.rb
Instance Method Summary collapse
Instance Method Details
#each(request = self.to_request) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/clientele/resource/pagination.rb', line 45 def each(request = self.to_request) return enum_for(:each, request) unless block_given? counter = 0 current_response = request.call until counter == total(current_response) do if pages(current_response).empty? current_response = request.tap do |request| next_page(request) end.call else counter +=1 yield pages(current_response).shift end end end |