lib/rom/sql/plugin/pagination.rb in rom-sql-3.6.4 vs lib/rom/sql/plugin/pagination.rb in rom-sql-4.0.0.alpha1
- old
+ new
@@ -1,9 +1,11 @@
# frozen_string_literal: true
-require 'rom/initializer'
+require "dry/core/equalizer"
+require "rom/initializer"
+
module ROM
module SQL
module Plugin
# Pagination plugin for Relations
#
@@ -51,11 +53,11 @@
# @return [Integer]
#
# @api public
def prev_page
num = current_page - 1
- num if num > 0
+ num if num.positive?
end
# Return total number of tuples
#
# @return [Integer]
@@ -98,10 +100,10 @@
def at(dataset, current_page, per_page = self.per_page)
current_page = current_page.to_i
per_page = per_page.to_i
self.class.new(
- dataset.offset((current_page-1)*per_page).limit(per_page),
+ dataset.offset((current_page - 1) * per_page).limit(per_page),
current_page: current_page, per_page: per_page
)
end
alias_method :limit_value, :per_page