class PactBroker::Matrix::Integration

Attributes

consumer_id[R]
consumer_name[R]
provider_id[R]
provider_name[R]

Public Class Methods

from_hash(hash) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 22
def self.from_hash hash
  new(
    hash.fetch(:consumer_id),
    hash.fetch(:consumer_name),
    hash.fetch(:provider_id),
    hash.fetch(:provider_name),
    hash.fetch(:required)
  )
end
new(consumer_id, consumer_name, provider_id, provider_name, required) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 14
def initialize consumer_id, consumer_name, provider_id, provider_name, required
  @consumer_id = consumer_id
  @consumer_name = consumer_name
  @provider_id = provider_id
  @provider_name = provider_name
  @required = required
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 48
def <=> other
  comparison = consumer_name <=> other.consumer_name
  return comparison if comparison != 0
  provider_name <=> other.provider_name
end
==(other) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 44
def == other
  other.is_a?(Integration) && consumer_id == other.consumer_id && provider_id == other.provider_id && other.required? == required?
end
consumer() click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 32
def consumer
  @consumer ||= OpenStruct.new(name: consumer_name, id: consumer_id)
end
involves_consumer_with_id?(consumer_id) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 71
def involves_consumer_with_id?(consumer_id)
  self.consumer_id == consumer_id
end
involves_consumer_with_name?(consumer_name) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 83
def involves_consumer_with_name?(consumer_name)
  self.consumer_name == consumer_name
end
involves_consumer_with_names?(consumer_names) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 75
def involves_consumer_with_names?(consumer_names)
  consumer_names.include?(self.consumer_name)
end
involves_pacticipant_with_name?(pacticipant_name) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 87
def involves_pacticipant_with_name?(pacticipant_name)
  pacticipant_names.include?(pacticipant_name)
end
involves_provider_with_name?(provider_name) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 79
def involves_provider_with_name?(provider_name)
  self.provider_name == provider_name
end
matches_pacticipant_ids?(other) click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 91
def matches_pacticipant_ids?(other)
  consumer_id == other.consumer_id && provider_id == other.provider_id
end
pacticipant_names() click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 63
def pacticipant_names
  [consumer_name, provider_name]
end
provider() click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 36
def provider
  @provider ||= OpenStruct.new(name: provider_name, id: provider_id)
end
required?() click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 40
def required?
  @required
end
to_hash() click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 54
def to_hash
  {
    consumer_name: consumer_name,
    consumer_id: consumer_id,
    provider_name: provider_name,
    provider_id: provider_id,
  }
end
to_s() click to toggle source
# File lib/pact_broker/matrix/integration.rb, line 67
def to_s
  "Integration between #{consumer_name} (id=#{consumer_id}) and #{provider_name} (id=#{provider_id}) required=#{required?}"
end