Class: JsonApiFilter::FieldFilters::Pagination
- Defined in:
- lib/json_api_filter/field_filters/pagination.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from JsonApiFilter::FieldFilters::Base
Instance Method Details
#predicate ⇒ ActiveRecord_Relation
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/json_api_filter/field_filters/pagination.rb', line 6 def predicate page = values["page"] per_page = values["perPage"] result = scope unless page.nil? || per_page.nil? || per_page == "-1" result = result.limit(per_page.to_i) result = result.offset((page.to_i - 1) * per_page.to_i) end result end |