Module: API::Helpers::PaginationStrategies

Included in:
API::Helpers
Defined in:
lib/api/helpers/pagination_strategies.rb

Instance Method Summary collapse

Instance Method Details

#paginate_with_strategies(relation, request_scope) ⇒ Object


6
7
8
9
10
11
12
# File 'lib/api/helpers/pagination_strategies.rb', line 6

def paginate_with_strategies(relation, request_scope)
  paginator = paginator(relation, request_scope)

  yield(paginator.paginate(relation)).tap do |records, _|
    paginator.finalize(records)
  end
end

#paginator(relation, request_scope = nil) ⇒ Object


14
15
16
17
18
# File 'lib/api/helpers/pagination_strategies.rb', line 14

def paginator(relation, request_scope = nil)
  return keyset_paginator(relation) if keyset_pagination_enabled?

  offset_paginator(relation, request_scope)
end