Module: Motor::ApiQuery::Paginate

Defined in:
lib/motor/api_query/paginate.rb

Constant Summary collapse

MAX_PER_PAGE =
500

Class Method Summary collapse

Class Method Details

.call(rel, params) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/motor/api_query/paginate.rb', line 10

def call(rel, params)
  params ||= {}

  rel = rel.limit([MAX_PER_PAGE, (params[:limit] || MAX_PER_PAGE).to_i].min)

  rel.offset(params[:offset].to_i)
end