Module: Jsonapi::QueryBuilder::Mixins::Paginate
- Extended by:
- ActiveSupport::Concern
- Included in:
- BaseQuery
- Defined in:
- lib/jsonapi/query_builder/mixins/paginate.rb
Instance Attribute Summary collapse
-
#pagination_details ⇒ Object
readonly
Returns the value of attribute pagination_details.
Instance Method Summary collapse
-
#paginate(collection, page_params = send(:page_params)) ⇒ ActiveRecord::Relation
Paginates the collection and returns the requested page.
Instance Attribute Details
#pagination_details ⇒ Object (readonly)
Returns the value of attribute pagination_details.
22 23 24 |
# File 'lib/jsonapi/query_builder/mixins/paginate.rb', line 22 def pagination_details @pagination_details end |
Instance Method Details
#paginate(collection, page_params = send(:page_params)) ⇒ ActiveRecord::Relation
Paginates the collection and returns the requested page. Also sets the pagination details that can be used for displaying metadata in the Json:Api response.
29 30 31 32 33 |
# File 'lib/jsonapi/query_builder/mixins/paginate.rb', line 29 def paginate(collection, page_params = send(:page_params)) records, @pagination_details = self.class._paginator.new(collection).paginate(page_params) records end |