Class: Gitlab::Pagination::OffsetPagination

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#finalize

Constructor Details

#initialize(request_context) ⇒ OffsetPagination

Returns a new instance of OffsetPagination.


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

def initialize(request_context)
  @request_context = request_context
end

Instance Attribute Details

#request_contextObject (readonly)

Returns the value of attribute request_context.


6
7
8
# File 'lib/gitlab/pagination/offset_pagination.rb', line 6

def request_context
  @request_context
end

Instance Method Details

#paginate(relation, exclude_total_headers: false, skip_default_order: false) ⇒ Object


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

def paginate(relation, exclude_total_headers: false, skip_default_order: false)
  paginate_with_limit_optimization(add_default_order(relation, skip_default_order: skip_default_order)).tap do |data|
    add_pagination_headers(data, exclude_total_headers)
  end
end