Module Sequel::DatasetPagination
In: lib/sequel/extensions/pagination.rb

Methods

Public Instance methods

Yields a paginated dataset for each page and returns the receiver. Does a count to find the total number of records for this dataset. Returns an enumerator if no block is given.

[Source]

    # File lib/sequel/extensions/pagination.rb, line 34
34:     def each_page(page_size)
35:       raise(Error, "You cannot paginate a dataset that already has a limit") if @opts[:limit]
36:       return to_enum(:each_page, page_size) unless block_given?
37:       record_count = count
38:       total_pages = (record_count / page_size.to_f).ceil
39:       (1..total_pages).each{|page_no| yield paginate(page_no, page_size, record_count)}
40:       self
41:     end

Returns a paginated dataset. The returned dataset is limited to the page size at the correct offset, and extended with the Pagination module. If a record count is not provided, does a count of total number of records for this dataset.

[Source]

    # File lib/sequel/extensions/pagination.rb, line 24
24:     def paginate(page_no, page_size, record_count=nil)
25:       raise(Error, "You cannot paginate a dataset that already has a limit") if @opts[:limit]
26:       paginated = limit(page_size, (page_no - 1) * page_size)
27:       paginated.extend(Dataset::Pagination)
28:       paginated.set_pagination_info(page_no, page_size, record_count || count)
29:     end

[Validate]