Sha256: d6731c4e5d95b0ca558119be7b21517012f7c0e45ddc9c25d10e627a9e87fe20

Contents?: true

Size: 1.66 KB

Versions: 38

Compression:

Stored size: 1.66 KB

Contents

require_relative 'base_decorator'
require_relative 'embedded_tag_decorator'

module PactBroker
  module Api
    module Decorators
      class VersionDecorator < BaseDecorator

        property :number

        collection :tags, embedded: true, :extend => PactBroker::Api::Decorators::EmbeddedTagDecorator

        link :self do | options |
          {
            title: 'Version',
            name: represented.number,
            href: version_url(options.fetch(:base_url), represented)
          }
        end

        link :'pb:pacticipant' do | options |
          {
            title: 'Pacticipant',
            name: represented.pacticipant.name,
            href: pacticipant_url(options.fetch(:base_url), represented.pacticipant)
          }
        end

        link :'pb:latest-verification-results-where-pacticipant-is-consumer' do | options |
          {
            title: "Latest verification results for consumer version",
            href: latest_verifications_for_consumer_version_url(represented, options.fetch(:base_url))
          }
        end

        links :'pb:pact-versions' do | context |
          sorted_pacts.collect do | pact |
            {
              title: "Pact",
              name: pact.name,
              href: pact_url(context[:base_url], pact),
            }
          end
        end

        curies do | options |
          [{
            name: :pb,
            href: options.fetch(:base_url) + '/doc/{rel}',
            templated: true
          }]
        end

        private

        def sorted_pacts
          represented.pact_publications.sort{ |a, b| a.provider_name.downcase <=> b.provider_name.downcase }
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
pact_broker-2.23.4 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.23.3 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.23.2 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.23.1 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.23.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.22.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.21.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.20.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.19.2 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.19.1 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.19.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.18.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.17.1 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.17.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.16.1 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.16.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.15.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.14.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.13.1 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.13.0 lib/pact_broker/api/decorators/version_decorator.rb