diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-02-02 16:37:11 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-02-02 16:37:11 +0300 |
commit | 030adf12ce6dc8e10a9f0bbb34ff55aa818d7aed (patch) | |
tree | f5e505f9bb882b4a38319d7c449f13ebf435185a /app/serializers/environment_serializer.rb | |
parent | ac06070147f23909dfb5d3468a17a29e6b0cd447 (diff) |
Encapsulate reused pagination component in a class
Diffstat (limited to 'app/serializers/environment_serializer.rb')
-rw-r--r-- | app/serializers/environment_serializer.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index 8624392e07f..c556424a414 100644 --- a/app/serializers/environment_serializer.rb +++ b/app/serializers/environment_serializer.rb @@ -7,12 +7,20 @@ class EnvironmentSerializer < BaseSerializer tap { @itemize = true } end + def with_pagination(request, response) + tap { @paginator = Paginator.new(request, response) } + end + def itemized? @itemize end + def paginated? + defined?(@paginator) + end + def represent(resource, opts = {}) - # resource = paginate(resource) if paginated? + resource = @paginator.paginate(resource) if paginated? if itemized? itemize(resource).map do |item| |