Module: RESTFramework::ListModelMixin
- Included in:
- ModelControllerMixin, ReadOnlyModelControllerMixin
- Defined in:
- lib/rest_framework/controller_mixins/models.rb
Overview
Mixin for listing records.
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/rest_framework/controller_mixins/models.rb', line 162 def index @records = self.get_filtered_data(self.get_recordset) # Handle pagination, if enabled. if self.class.paginator_class paginator = self.class.paginator_class.new(data: @records, controller: self) page = paginator.get_page serialized_page = self.get_serializer_class.new(object: page, controller: self).serialize data = paginator.get_paginated_response(serialized_page) else data = self.get_serializer_class.new(object: @records, controller: self).serialize end return api_response(data) end |