Sha256: d80a7a0d668f000ca4a74cfb8a0245b2b83b6e87874ce58b0d810ffeaaf94433
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
require "roar/decorator" require "roar/json/hal" module PactBroker module Api module Decorators module PaginationLinks include Roar::JSON::HAL include Roar::JSON::HAL::Links property :page, getter: lambda { |represented:, **| if represented.respond_to?(:current_page) { number: represented.current_page, size: represented.page_size, totalElements: represented.pagination_record_count, totalPages: represented.page_count, } end } link :next do | context | if represented.respond_to?(:current_page) && represented.respond_to?(:page_count) && represented.current_page < represented.page_count { href: context[:resource_url] + "?pageSize=#{represented.page_size}&pageNumber=#{represented.current_page + 1}", title: "Next page" } end end link :previous do | context | if represented.respond_to?(:first_page?) && !represented.first_page? { href: context[:resource_url] + "?pageSize=#{represented.page_size}&pageNumber=#{represented.current_page - 1}", title: "Previous page" } end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems