Sha256: 64d856739df097aefb8e4361c483ab9b0652af7e0f4d8f11eec4d0b7c4d20068

Contents?: true

Size: 424 Bytes

Versions: 3

Compression:

Stored size: 424 Bytes

Contents

module Dune
  module Api
    module PaginatedController
      extend ActiveSupport::Concern

      included do
        has_scope :page, default: 1
      end

      def respond_with_pagination(collection)
        render json: collection, meta: {
          page:        collection.current_page,
          total:       collection.total_count,
          total_pages: collection.total_pages
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dune-api-1.1.0 lib/dune/api/paginated_controller.rb
dune-api-1.0.2 lib/dune/api/paginated_controller.rb
dune-api-1.0.1 lib/dune/api/paginated_controller.rb