Sha256: 6db4da8fef50e416ab89aaa3c23269c00c9f27878f4da43f5da147dcb196dbd9

Contents?: true

Size: 1.68 KB

Versions: 27

Compression:

Stored size: 1.68 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}?context=version',
            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

27 entries across 27 versions & 1 rubygems

Version Path
pact_broker-2.43.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.42.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.41.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.40.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.39.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.38.1 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.38.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.37.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.36.1 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.36.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.35.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.34.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.33.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.32.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.31.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.30.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.29.0 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.27.6 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.27.5 lib/pact_broker/api/decorators/version_decorator.rb
pact_broker-2.27.4 lib/pact_broker/api/decorators/version_decorator.rb