Module: Pagy::OverflowExtra::Countless

Included in:
Countless
Defined in:
lib/pagy/extras/overflow.rb

Overview

Support for Pagy::Countless class

Instance Method Summary collapse

Instance Method Details

#finalize(items) ⇒ Object

Add rescue clause for different behaviors



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/pagy/extras/overflow.rb', line 53

def finalize(items)
  @overflow = false
  super
rescue OverflowError
  @overflow = true                        # add the overflow flag
  case @vars[:overflow]
  when :exception
    raise                                 # same as without the extra
  when :empty_page
    @offset = @items = @from = @to = 0    # vars relative to the actual page
    @vars[:size] = []                     # no page in the series
    self
  else
    raise VariableError.new(self), \
          "expected :overflow to be in [:empty_page, :exception]; got #{@vars[:overflow].inspect}"
  end
end