Skip to content

Commit

Permalink
fix for ArgumentError feedback in Pagy constructor should show the or…
Browse files Browse the repository at this point in the history
…iginally passed offending value (#104)
  • Loading branch information
ddnexus committed Nov 13, 2018
1 parent a86b59a commit e8a2251
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pagy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(vars)
@vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars
{ count:0, items:1, outset:0, page:1 }.each do |k,min| # validate instance variables
(@vars[k] && instance_variable_set(:"@#{k}", @vars[k].to_i) >= min) \
or raise(ArgumentError, "expected :#{k} >= #{min}; got #{instance_variable_get(:"@#{k}").inspect}")
or raise(ArgumentError, "expected :#{k} >= #{min}; got #{@vars[k].inspect}")
end
@pages = @last = [(@count.to_f / @items).ceil, 1].max # cardinal and ordinal meanings
@page <= @last or raise(OutOfRangeError.new(self), "expected :page in 1..#{@last}; got #{@page.inspect}")
Expand Down

0 comments on commit e8a2251

Please sign in to comment.