Sha256: cd178668331a808d836f6bd40e677109babf08ea2c417a20354759f8c19027e8

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

require_relative 'base_decorator'
require_relative 'version_decorator'
require_relative 'latest_pact_decorator'
require_relative 'representable_pact'

module PactBroker

  module Api

    module Decorators

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

        collection :pacts, exec_context: :decorator, :class => PactBroker::Models::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 :pacts do | options |
          represented.collect{ | pact | {:href => latest_pact_url(options[:base_url], pact), :title => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}" } }
        end

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pact_broker-1.3.1 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-1.3.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-1.2.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-1.1.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-1.0.0 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-1.0.0.alpha3 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-1.0.0.alpha2 lib/pact_broker/api/decorators/pact_collection_decorator.rb
pact_broker-1.0.0.alpha1 lib/pact_broker/api/decorators/pact_collection_decorator.rb