Module: RESTFramework::Mixins::ListModelMixin
- Included in:
- ModelControllerMixin, ReadOnlyModelControllerMixin
- Defined in:
- lib/rest_framework/mixins/model_controller_mixin.rb
Overview
Mixin for listing records.
Instance Method Summary collapse
-
#get_index_records ⇒ Object
Get records with both filtering and pagination applied.
- #index ⇒ Object
Instance Method Details
#get_index_records ⇒ Object
Get records with both filtering and pagination applied.
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
# File 'lib/rest_framework/mixins/model_controller_mixin.rb', line 641 def get_index_records records = self.get_records # Handle pagination, if enabled. if self.paginator_class # If there is no `max_page_size`, `page_size_query_param` is not `nil`, and the page size is # set to "0", then skip pagination. unless !self.max_page_size && self.page_size_query_param && params[self.page_size_query_param] == "0" paginator = self.paginator_class.new(data: records, controller: self) page = paginator.get_page serialized_page = self.serialize(page) return paginator.get_paginated_response(serialized_page) end end return records end |
#index ⇒ Object
636 637 638 |
# File 'lib/rest_framework/mixins/model_controller_mixin.rb', line 636 def index return api_response(self.get_index_records) end |