Class: CursorPaginator::Paginator::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/cursor_paginator/paginator/array.rb

Constant Summary

Constants inherited from Base

Base::SORT_DIRECTIONS

Instance Attribute Summary

Attributes inherited from Base

#options_parser, #paginator_options

Instance Method Summary collapse

Methods inherited from Base

#initialize, #take_records

Constructor Details

This class inherits a constructor from CursorPaginator::Paginator::Base

Instance Method Details

#paginate(scope) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/cursor_paginator/paginator/array.rb', line 4

def paginate(scope)
  records = scope.sort_by(&paginator_options.fetch(:order_key))
  records = filter_by_cursor(records) if options_parser.filter_required?
  records = records.reverse if order_direction == :desc

  PaginationResult.new(records, self)
end