Class: Gitlab::Pagination::Keyset::Pager

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/pagination/keyset/pager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Pager

Returns a new instance of Pager.


9
10
11
# File 'lib/gitlab/pagination/keyset/pager.rb', line 9

def initialize(request)
  @request = request
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.


7
8
9
# File 'lib/gitlab/pagination/keyset/pager.rb', line 7

def request
  @request
end

Instance Method Details

#finalize(records) ⇒ Object


20
21
22
# File 'lib/gitlab/pagination/keyset/pager.rb', line 20

def finalize(records)
  apply_headers(records.last)
end

#paginate(relation) ⇒ Object


13
14
15
16
17
18
# File 'lib/gitlab/pagination/keyset/pager.rb', line 13

def paginate(relation)
  # Validate assumption: The last two columns must match the page order_by
  validate_order!(relation)

  relation.limit(page.per_page) # rubocop: disable CodeReuse/ActiveRecord
end