Class: Pagy::Offset::Countless

Inherits:
Pagy::Offset show all
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

DEFAULT

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

Methods included from Deprecated::Countless

#upto_max_pages

Methods included from NumericHelpers

#info_tag, #input_nav_js, #limit_tag_js, #previous_tag, #series_nav, #series_nav_js

Methods included from Rangeable

#in_range?

Methods included from Deprecated::Offset

#assign_last

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

#assign_options

Methods included from Deprecated::Pagy

#assign_options

Constructor Details

#initializeCountless

Returns a new instance of Countless.



7
8
9
10
11
12
# File 'lib/pagy/classes/offset/countless.rb', line 7

def initialize(**)
  assign_options(**)
  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