Commit 81eb5c7f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Move serializers pagination class to separate module

This helps to avoid conflicts with `Paginator` class that seems to be
used by some bundled libs.
parent 10c1a4d8
...@@ -8,7 +8,7 @@ class EnvironmentSerializer < BaseSerializer ...@@ -8,7 +8,7 @@ class EnvironmentSerializer < BaseSerializer
end end
def with_pagination(request, response) def with_pagination(request, response)
tap { @paginator = Paginator.new(request, response) } tap { @paginator = Gitlab::Serializer::Pagination.new(request, response) }
end end
def itemized? def itemized?
......
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
...@@ -4,7 +4,7 @@ class PipelineSerializer < BaseSerializer ...@@ -4,7 +4,7 @@ class PipelineSerializer < BaseSerializer
entity PipelineEntity entity PipelineEntity
def with_pagination(request, response) def with_pagination(request, response)
tap { @paginator = Paginator.new(request, response) } tap { @paginator = Gitlab::Serializer::Pagination.new(request, response) }
end end
def paginated? def paginated?
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment