ministryofjustice/Claim-for-Crown-Court-Defence

View on GitHub
app/interfaces/api/entities/paginated_collection.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
module API
  module Entities
    class PaginatedCollection < BaseEntity
      present_collection true

      expose :pagination do
        expose :current_page
        expose :total_pages
        expose :total_count
        expose :limit_value
      end

      expose :items, using: API::Entities::Claim

      private

      def items
        object[:items]
      end

      def current_page
        items.current_page
      end

      def total_pages
        items.total_pages
      end

      def total_count
        items.total_count
      end

      def limit_value
        items.limit_value
      end
    end
  end
end