Module: Gitlab::Pagination::Keyset

Defined in:
lib/gitlab/pagination/keyset.rb,
lib/gitlab/pagination/keyset/page.rb,
lib/gitlab/pagination/keyset/pager.rb,
lib/gitlab/pagination/keyset/header_builder.rb,
lib/gitlab/pagination/keyset/request_context.rb

Defined Under Namespace

Classes: HeaderBuilder, Page, Pager, RequestContext

Constant Summary collapse

SUPPORTED_TYPES =
[
  Project
].freeze

Class Method Summary collapse

Class Method Details

.available?(request_context, relation) ⇒ Boolean

Returns:

  • (Boolean)

14
15
16
17
18
19
20
21
# File 'lib/gitlab/pagination/keyset.rb', line 14

def self.available?(request_context, relation)
  order_by = request_context.page.order_by

  return false unless available_for_type?(relation)
  return false unless order_by.size == 1 && order_by[:id]

  true
end

.available_for_type?(relation) ⇒ Boolean

Returns:

  • (Boolean)

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

def self.available_for_type?(relation)
  SUPPORTED_TYPES.include?(relation.klass)
end