lib/pagy.rb in pagy-5.1.3 vs lib/pagy.rb in pagy-5.2.0

- old
+ new

@@ -3,11 +3,11 @@ require 'pathname' # Core class class Pagy - VERSION = '5.1.3' + VERSION = '5.2.0' # Root pathname to get the path of Pagy files like templates or dictionaries def self.root @root ||= Pathname.new(__dir__).freeze end @@ -44,10 +44,10 @@ # Return the array of page numbers and :gap items e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36] def series(size = @vars[:size]) return [] if size.empty? raise VariableError.new(self, :size, 'to contain 4 items >= 0', size) \ - unless size.size == 4 && size.all? { |num| !num.negative? rescue false } # rubocop:disable Style/RescueModifier + unless size.is_a?(Array) && size.size == 4 && size.all? { |num| !num.negative? rescue false } # rubocop:disable Style/RescueModifier # This algorithm is up to ~5x faster and ~2.3x lighter than the previous one (pagy < 4.3) left_gap_start = 1 + size[0] # rubocop:disable Layout/ExtraSpacing, Layout/SpaceAroundOperators left_gap_end = @page - size[1] - 1 right_gap_start = @page + size[2] + 1