Module: Pagy::Countless::UseOverflowExtra

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

Instance Method Summary collapse

Instance Method Details

#finalize(items) ⇒ Object



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

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 variable in [:empty_page, :exception]; got #{@vars[:overflow].inspect}"
  end
end