Class: Pagy::Offset::Countless
- Inherits:
-
Pagy::Offset
- Object
- Pagy
- Pagy::Offset
- Pagy::Offset::Countless
- Includes:
- Deprecated::Countless
- Defined in:
- lib/pagy/classes/offset/countless.rb
Overview
Offset pagination without any COUNT query
Constant Summary
Constants inherited from Pagy::Offset
Constants inherited from Pagy
A_TAG, DEFAULT, DEFAULT_DATA_KEYS, DEFAULT_HEADERS_MAP, LABEL_TOKEN, LIMIT_TOKEN, Method, Pagy::OPTIONS, PAGE_TOKEN, ROOT, SERIES_SLOTS, VERSION
Instance Attribute Summary
Attributes inherited from Pagy::Offset
#count, #from, #in, #last, #next, #offset, #previous, #to
Attributes inherited from Pagy
#in, #limit, #next, #options, #page
Instance Method Summary collapse
-
#initialize ⇒ Countless
constructor
A new instance of Countless.
- #records(collection) ⇒ Object
Methods included from Deprecated::Countless
Methods included from NumericHelpers
#info_tag, #input_nav_js, #limit_tag_js, #previous_tag, #series_nav, #series_nav_js
Methods included from Rangeable
Methods included from Deprecated::Offset
Methods inherited from Pagy
#data_hash, #headers_hash, #next_tag, #page_url, #urls_hash
Methods included from Configurable
#dev_tools, #options, #sync, #sync_javascript, #translate_with_the_slower_i18n_gem!
Methods included from Discontinued
Methods included from Deprecated::Pagy
Constructor Details
#initialize ⇒ Countless
Returns a new instance of Countless.
7 8 9 10 11 12 |
# File 'lib/pagy/classes/offset/countless.rb', line 7 def initialize(**) (**) assign_and_check(limit: 1, page: 1) @last = @options[:last] unless @options[:headless] assign_offset end |
Instance Method Details
#records(collection) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/pagy/classes/offset/countless.rb', line 14 def records(collection) return super if @options[:headless] fetched = collection.offset(@offset).limit(@limit + 1).to_a # eager load limit + 1 finalize(fetched.size) # finalize the pagy object fetched[0, @limit] # ignore the extra item end |