Class: PactBroker::Matrix::QueryIds

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/matrix/query_ids.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(all_pacticipant_ids, specified_pacticipant_ids, pacticipant_ids, pacticipant_version_ids) ⇒ QueryIds

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



10
11
12
13
14
15
16
# File 'lib/pact_broker/matrix/query_ids.rb', line 10

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

Instance Attribute Details

#all_pacticipant_idsObject (readonly)

Returns the value of attribute all_pacticipant_ids.



4
5
6
# File 'lib/pact_broker/matrix/query_ids.rb', line 4

def all_pacticipant_ids
  @all_pacticipant_ids
end

#pacticipant_idsObject (readonly)

Returns the value of attribute pacticipant_ids.



4
5
6
# File 'lib/pact_broker/matrix/query_ids.rb', line 4

def pacticipant_ids
  @pacticipant_ids
end

#pacticipant_version_idsObject (readonly)

Returns the value of attribute pacticipant_version_ids.



4
5
6
# File 'lib/pact_broker/matrix/query_ids.rb', line 4

def pacticipant_version_ids
  @pacticipant_version_ids
end

#specified_pacticipant_idsObject (readonly)

Returns the value of attribute specified_pacticipant_ids.



4
5
6
# File 'lib/pact_broker/matrix/query_ids.rb', line 4

def specified_pacticipant_ids
  @specified_pacticipant_ids
end

Class Method Details

.collect_ids(hashes, key) ⇒ Object



27
28
29
# File 'lib/pact_broker/matrix/query_ids.rb', line 27

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

.from_selectors(selectors) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/pact_broker/matrix/query_ids.rb', line 18

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

Instance Method Details

#pacticipant_idObject



31
32
33
# File 'lib/pact_broker/matrix/query_ids.rb', line 31

def pacticipant_id
  pacticipant_ids.first
end

#pacticipant_version_idObject



35
36
37
# File 'lib/pact_broker/matrix/query_ids.rb', line 35

def pacticipant_version_id
  pacticipant_version_ids.first
end