summaryrefslogtreecommitdiff
path: root/app/serializers/paginator.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-02 14:37:11 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-02 14:37:11 +0100
commit030adf12ce6dc8e10a9f0bbb34ff55aa818d7aed (patch)
treef5e505f9bb882b4a38319d7c449f13ebf435185a /app/serializers/paginator.rb
parentac06070147f23909dfb5d3468a17a29e6b0cd447 (diff)
downloadgitlab-ce-030adf12ce6dc8e10a9f0bbb34ff55aa818d7aed.tar.gz
Encapsulate reused pagination component in a class
Diffstat (limited to 'app/serializers/paginator.rb')
-rw-r--r--app/serializers/paginator.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/serializers/paginator.rb b/app/serializers/paginator.rb
new file mode 100644
index 00000000000..c5e38a9c8b5
--- /dev/null
+++ b/app/serializers/paginator.rb
@@ -0,0 +1,23 @@
+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