Sha256: bb6262cad0d862be6b174e3055b4f1b4ae23ae995c2dee5404e32e28e1f75357

Contents?: true

Size: 1.73 KB

Versions: 70

Compression:

Stored size: 1.73 KB

Contents

require_relative 'base_decorator'
require_relative 'embedded_version_decorator'
require_relative 'latest_pact_decorator'
require_relative 'representable_pact'

module PactBroker
  module Api
    module Decorators
      class PactCollectionDecorator < BaseDecorator
        include Roar::JSON::HAL
        include PactBroker::Api::PactBrokerUrls

        collection :pacts, exec_context: :decorator, :class => PactBroker::Domain::Pact, :extend => PactBroker::Api::Decorators::LatestPactDecorator

        def pacts
          represented.collect{ | pact | create_representable_pact(pact) }
        end

        def create_representable_pact pact
          PactBroker::Api::Decorators::RepresentablePact.new(pact)
        end

        link :self do | options |
          latest_pacts_url(options[:base_url])
        end

        # This is the LATEST pact URL
        links :'pb:pacts' do | options |
          represented.collect do | pact |
            {
              :href => latest_pact_url(options[:base_url], pact),
              :title => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}",
            }
          end
        end

        # This is the LATEST pact URL
        links :pacts do | options |
          represented.collect do | pact |
            {
              :href => latest_pact_url(options[:base_url], pact),
              :title => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}",
              :name => "DEPRECATED - please use the pb:pacts relation"
            }
          end
        end

        curies do | options |
          [{
            name: :pb,
            href: options[:base_url] + '/doc/{rel}?context=pacts',
            templated: true
          }]
        end
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
pact_broker-2.74.1 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.74.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.73.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.72.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.71.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.70.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.69.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.68.1 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.68.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.67.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.66.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.65.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.64.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.63.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.62.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.61.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.60.1 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.60.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.59.2 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-2.59.1 lib/pact_broker/api/decorators/pact_collection_decorator.rb