Move serializers pagination class to separate module

This helps to avoid conflicts with `Paginator` class that seems to be
used by some bundled libs.
This commit is contained in:
Grzegorz Bizon 2017-02-06 14:47:56 +01:00
parent 10c1a4d8e4
commit 81eb5c7fd7
4 changed files with 29 additions and 25 deletions

View File

@ -8,7 +8,7 @@ class EnvironmentSerializer < BaseSerializer
end
def with_pagination(request, response)
tap { @paginator = Paginator.new(request, response) }
tap { @paginator = Gitlab::Serializer::Pagination.new(request, response) }
end
def itemized?

View File

@ -1,23 +0,0 @@
class Paginator
include API::Helpers::Pagination
def initialize(request, response)
@request = request
@response = response
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

View File

@ -4,7 +4,7 @@ class PipelineSerializer < BaseSerializer
entity PipelineEntity
def with_pagination(request, response)
tap { @paginator = Paginator.new(request, response) }
tap { @paginator = Gitlab::Serializer::Pagination.new(request, response) }
end
def paginated?

View File

@ -0,0 +1,27 @@
module Gitlab
module Serializer
class Pagination
include ::API::Helpers::Pagination
def initialize(request, response)
@request = request
@response = response
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