Class: Pagy::Offset::Countless
- Inherits:
-
Offset
- Object
- Offset
- Pagy::Offset::Countless
- Includes:
- Deprecated::Countless
- Defined in:
- lib/pagy/classes/offset/countless.rb
Overview
Offset pagination without any COUNT query
Instance Method Summary collapse
-
#initialize ⇒ Countless
constructor
A new instance of Countless.
- #records(collection) ⇒ Object
Methods included from Deprecated::Countless
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 |