lib/yap/params_extractor.rb in yap-1.4.2 vs lib/yap/params_extractor.rb in yap-2.0.0
- old
+ new
@@ -34,10 +34,11 @@
rescue ArgumentError
raise PaginationError, "'#{number}' is not a valid number."
end
raise PaginationError, 'Only positive numbers are accepted.' unless number > 0
+
number
end
def extract_order(params)
sort, direction = params.values_at(:sort, :direction)
@@ -81,19 +82,19 @@
(sort =~ /\./ ? "#{sort} #{direction}" : { sort => direction })
end
def extract_column(sort)
- column = map_column(sort.to_s.downcase)
+ column = map_column(sort.to_s)
raise PaginationError, "Cannot sort by '#{sort}'." unless column
column
end
def extract_direction(direction)
direction ||= DEFAULTS.direction
dir = direction.to_sym.downcase
- unless [:asc, :desc].include? dir
+ unless %i[asc desc].include? dir
raise PaginationError, "'#{direction}' is not a valid direction. Use 'asc' or 'desc'."
end
dir
end