Sha256: ac077865adeaeb40e85f5a0428602441ceecda4b0593924c29a5cd544d128559
Contents?: true
Size: 473 Bytes
Versions: 8
Compression:
Stored size: 473 Bytes
Contents
module Braintree class PaginatedCollection include Enumerable def initialize(&block) @next_page_block = block end def each(&block) current_page = 0 total_items = 0 loop do current_page += 1 result = @next_page_block.call(current_page) total_items = result.total_items result.current_page.each(&block) break if current_page * result.page_size >= total_items end end end end
Version data entries
8 entries across 8 versions & 1 rubygems