main
1# frozen_string_literal: true
2
3module Pageable
4 extend ActiveSupport::Concern
5
6 included do
7 def paginate(query, page: 0, page_size: 25)
8 Paginate.new(query, page: page, page_size: page_size)
9 end
10
11 def page_param(key, default:, bottom: 0, top: 250)
12 actual = params.fetch(key, default).to_i
13 return bottom if actual < bottom
14 return top if actual > top
15
16 actual
17 end
18 end
19end