Sha256: 653f1843040c7f4f1a051e5604e6853a3627c60403028a52517820f7d2926644
Contents?: true
Size: 1.24 KB
Versions: 19
Compression:
Stored size: 1.24 KB
Contents
# See Pagy::Countless API documentation: https://ddnexus.github.io/pagy/docs/api/countless # frozen_string_literal: true class Pagy # :nodoc: # No need to know the count to paginate class Countless < Pagy # Merge and validate the options, do some simple arithmetic and set a few instance variables def initialize(**vars) # rubocop:disable Lint/MissingSuper assign_vars(DEFAULT, vars) assign_and_check(page: 1, outset: 0) assign_limit assign_offset end # Finalize the instance variables based on the fetched size def finalize(fetched_size) raise OverflowError.new(self, :page, "to be < #{@page}", @page) if fetched_size.zero? && @page > 1 @last = fetched_size > @limit ? @page + 1 : @page @last = @vars[:max_pages] if @vars[:max_pages] && @last > @vars[:max_pages] check_overflow @in = [fetched_size, @limit].min @from = @in.zero? ? 0 : @offset - @outset + 1 @to = @offset - @outset + @in assign_prev_and_next self end end module SeriesOverride # :nodoc: # Override the original series. # Return nil if :countless_minimal is enabled def series(**) super unless @vars[:countless_minimal] end end prepend SeriesOverride end
Version data entries
19 entries across 19 versions & 1 rubygems