gitlab-org--gitlab-foss/lib/gitlab/serializer/pagination.rb
2017-02-06 15:07:13 +01:00

36 lines
694 B
Ruby

module Gitlab
module Serializer
class Pagination
class InvalidResourceError < StandardError; end
include ::API::Helpers::Pagination
def initialize(request, response)
@request = request
@response = response
end
def paginate(resource)
if resource.respond_to?(:page)
super(resource)
else
raise InvalidResourceError
end
end
private
# Methods needed by `API::Helpers::Pagination`
#
attr_reader :request
def params
@request.query_parameters
end
def header(header, value)
@response.headers[header] = value
end
end
end
end