Module: PackAPI::Pagination
- Defined in:
- lib/pack_api/pagination/paginator.rb,
lib/pack_api.rb,
lib/pack_api/pagination/opaque_token_v2.rb,
lib/pack_api/pagination/paginator_cursor.rb,
lib/pack_api/pagination/paginator_builder.rb,
lib/pack_api/pagination/snapshot_paginator.rb
Overview
Make it easier to correctly instantiate a Paginator object, given that a few different use cases exist each having different data (arguments).
This is an application of the Builder pattern (see refactoring.guru/design-patterns/builder) for Ruby.
Two scenarios exist for constructing a Paginator object:
-
Starting a new query.
Uses the following parameters:
* query - filters used to define the recordset
* sort - ordering used to define the recordset
* per_page - count of items to include on each result page
* offset - starting index of the next result page
* total_items - count of items in the result set, if known
OR
-
Continuing an existing query
Uses the following parameters:
* a pagination cursor
* sort (optional) - Used to override the sort order of the cursor; effectively creates a new query
* per_page (optional) - Used to override the per_page of the cursor; will limit the count of results in the
Defined Under Namespace
Classes: OpaqueTokenV2, Paginator, PaginatorBuilder, PaginatorCursor, SnapshotPaginator