Class: CursorPaginator::Paginator::ActiveRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/cursor_paginator/paginator/active_record.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

Constructor Details

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

Instance Method Details

#paginate(scope) ⇒ Object



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

def paginate(scope)
  records = scope.reorder(paginator_options.fetch(:order_key) => order_direction)
  records = filter_by_cursor(records) if options_parser.filter_required?

  PaginationResult.new(records, self)
end

#take_records(records, limit) ⇒ Object



11
12
13
14
15
# File 'lib/cursor_paginator/paginator/active_record.rb', line 11

def take_records(records, limit)
  return super if records.limit_value.blank?

  super(records, [ records.limit_value, limit ].min)
end