Sha256: ac2eadd7bb7131f9db7e278b8ae3a93ad2e47b168127e00d264e884d82d2e2a5

Contents?: true

Size: 1.88 KB

Versions: 89

Compression:

Stored size: 1.88 KB

Contents

module PactBroker
  module Matrix
    class QueryIds
      attr_reader :all_pacticipant_ids, :specified_pacticipant_ids, :pacticipant_ids, :pacticipant_version_ids

      # pacticipant_version_ids - the pacticipant version ids from the selectors where the pacticipant version id is the most specific criterion
      # pacticipant_ids - the pacticipant ids from the selectors where the pacticipant id is the most specific criterion
      # all_pacticipant_ids - the pacticipant ids from all the selectors, regardless of whether or not a pacticipant version has also been specified
      # specified_pacticipant_ids the IDs of the pacticipants that were specified in the can-i-deploy query
      def initialize(all_pacticipant_ids, specified_pacticipant_ids, pacticipant_ids, pacticipant_version_ids)
        @all_pacticipant_ids = all_pacticipant_ids
        @specified_pacticipant_ids = specified_pacticipant_ids
        @pacticipant_ids = pacticipant_ids
        @pacticipant_version_ids = pacticipant_version_ids
        @all_pacticipant_ids = all_pacticipant_ids
      end

      def self.from_selectors(selectors)
        most_specific_criteria = selectors.collect(&:most_specific_criterion)
        all_pacticipant_ids = selectors.collect(&:pacticipant_id)
        specified_pacticipant_ids = selectors.select(&:specified?).collect(&:pacticipant_id)
        pacticipant_version_ids = collect_ids(most_specific_criteria, :pacticipant_version_id)
        pacticipant_ids = collect_ids(most_specific_criteria, :pacticipant_id)
        QueryIds.new(all_pacticipant_ids, specified_pacticipant_ids, pacticipant_ids, pacticipant_version_ids)
      end

      def self.collect_ids(hashes, key)
        hashes.collect{ |s| s[key] }.flatten.compact
      end

      def pacticipant_id
        pacticipant_ids.first
      end

      def pacticipant_version_id
        pacticipant_version_ids.first
      end
    end
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
pact_broker-2.93.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.92.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.91.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.90.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.89.1 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.89.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.88.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.87.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.86.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.85.1 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.85.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.84.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.83.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.82.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.81.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.80.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.79.1 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.79.0 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.78.1 lib/pact_broker/matrix/query_ids.rb
pact_broker-2.78.0 lib/pact_broker/matrix/query_ids.rb