Sha256: 905c7bad26c6f1b3604dac39425edabfb0933251fdc85d698ef823fa96859a29

Contents?: true

Size: 909 Bytes

Versions: 42

Compression:

Stored size: 909 Bytes

Contents

require 'delegate'

module PactBroker
  module Pacts
    class SelectedPact < SimpleDelegator
      attr_reader :pact, :selectors

      def initialize(pact, selectors)
        super(pact)
        @pact = pact
        @selectors = selectors
      end

      def self.merge(selected_pacts)
        latest_selected_pact = selected_pacts.sort_by(&:consumer_version_order).last
        selectors = selected_pacts.collect(&:selectors).reduce(&:+)
        SelectedPact.new(latest_selected_pact.pact, selectors)
      end

      def tag_names_of_selectors_for_latest_pacts
        selectors.tag_names_of_selectors_for_latest_pacts
      end

      def overall_latest?
        selectors.overall_latest?
      end

      def latest_for_tag? potential_tag = nil
        selectors.latest_for_tag?(potential_tag)
      end

      def consumer_version_order
        pact.consumer_version.order
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
pact_broker-2.76.2 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.76.1 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.76.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.75.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.74.1 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.74.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.73.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.72.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.71.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.70.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.69.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.68.1 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.68.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.67.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.66.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.65.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.64.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.63.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.62.0 lib/pact_broker/pacts/selected_pact.rb
pact_broker-2.61.0 lib/pact_broker/pacts/selected_pact.rb