Sha256: 0706c80c1a704dd3cc60daa6a1f69e62a9b5f2c382a1a9b62bebdf7351c339ba
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 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 { |context| if context[:represented].respond_to?(:current_page) { number: context[:represented].current_page, size: context[:represented].page_size, totalElements: context[:represented].pagination_record_count, totalPages: context[: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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pact_broker-2.106.0 | lib/pact_broker/api/decorators/pagination_links.rb |