Sha256: 2007365e4b9c58e9d5ee1052a6d3a03005d6740391e78aee1cdcc785337d5987

Contents?: true

Size: 988 Bytes

Versions: 20

Compression:

Stored size: 988 Bytes

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

        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

20 entries across 20 versions & 1 rubygems

Version Path
pact_broker-2.79.1 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.79.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.78.1 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.78.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.77.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.76.2 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.76.1 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.76.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.75.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.74.1 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.74.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.73.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.72.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.71.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.70.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.69.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.68.1 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.68.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.67.0 lib/pact_broker/api/decorators/pagination_links.rb
pact_broker-2.66.0 lib/pact_broker/api/decorators/pagination_links.rb