Class: CoreLibrary::PaginationStrategy
- Inherits:
-
Object
- Object
- CoreLibrary::PaginationStrategy
- Defined in:
- lib/apimatic-core/pagination/pagination_strategy.rb
Overview
Abstract base class for implementing pagination strategies.
Provides methods to initialize with pagination metadata, apply pagination logic to request builders, and update request builders with new pagination parameters based on JSON pointers.
Direct Known Subclasses
CursorPagination, LinkPagination, OffsetPagination, PagePagination
Instance Attribute Summary collapse
-
#metadata_wrapper ⇒ Object
readonly
Returns the value of attribute metadata_wrapper.
Instance Method Summary collapse
-
#applicable?(response) ⇒ boolean
Checks whether the pagination strategy is a valid candidate based on the given HTTP response.
-
#apply(paginated_data) ⇒ Object
Modifies the request builder to fetch the next page of results based on the provided paginated data.
-
#apply_metadata_wrapper(paged_response) ⇒ Object
Processes the paged API response using the metadata wrapper.
-
#initialize(metadata_wrapper) ⇒ PaginationStrategy
constructor
Initializes the PaginationStrategy with the provided metadata wrapper.
Constructor Details
#initialize(metadata_wrapper) ⇒ PaginationStrategy
Initializes the PaginationStrategy with the provided metadata wrapper.
13 14 15 16 17 |
# File 'lib/apimatic-core/pagination/pagination_strategy.rb', line 13 def initialize() raise ArgumentError, 'Metadata wrapper for the pagination cannot be nil' if .nil? = end |
Instance Attribute Details
#metadata_wrapper ⇒ Object (readonly)
Returns the value of attribute metadata_wrapper.
7 8 9 |
# File 'lib/apimatic-core/pagination/pagination_strategy.rb', line 7 def end |
Instance Method Details
#applicable?(response) ⇒ boolean
Checks whether the pagination strategy is a valid candidate based on the given HTTP response.
24 25 26 |
# File 'lib/apimatic-core/pagination/pagination_strategy.rb', line 24 def applicable?(response) raise NotImplementedError, 'Subclasses must implement #is_applicable' end |
#apply(paginated_data) ⇒ Object
Modifies the request builder to fetch the next page of results based on the provided paginated data.
33 34 35 |
# File 'lib/apimatic-core/pagination/pagination_strategy.rb', line 33 def apply(paginated_data) raise NotImplementedError, 'Subclasses must implement #apply' end |
#apply_metadata_wrapper(paged_response) ⇒ Object
Processes the paged API response using the metadata wrapper.
42 43 44 |
# File 'lib/apimatic-core/pagination/pagination_strategy.rb', line 42 def (paged_response) raise NotImplementedError, 'Subclasses must implement #apply_metadata_wrapper' end |