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:
parent
10c1a4d8e4
commit
81eb5c7fd7
|
@ -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?
|
||||
|
|
|
@ -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
|
|
@ -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?
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue