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

#_indexObject



209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/rest_framework/controller_mixins/models.rb', line 209

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(page, controller: self).serialize
    return paginator.get_paginated_response(serialized_page)
  else
    return self.get_serializer_class.new(@records, controller: self).serialize
  end
end

#indexObject



205
206
207
# File 'lib/rest_framework/controller_mixins/models.rb', line 205

def index
  api_response(self._index)
end