Class: Tablets::Data::Processing::Paginate

Inherits:
Base
  • Object
show all
Defined in:
lib/tablets/data/processing/paginate.rb

Overview

Incapsulate relation pagination logic.

Instance Method Summary collapse

Methods inherited from Base

apply, #initialize

Constructor Details

This class inherits a constructor from Tablets::Data::Processing::Base

Instance Method Details

#apply(relation) ⇒ Object

Applies :start and :length from params to relation as offset and limit. :length is optional. Default value is used if no length is provided. :start recalculated to match beginnning of page.



12
13
14
# File 'lib/tablets/data/processing/paginate.rb', line 12

def apply(relation)
  relation.offset(offset).limit(per_page)
end