Class: PactBroker::Domain::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/domain/relationship.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(consumer, provider, latest_pact = nil, latest_verification = nil) ⇒ Relationship

Returns a new instance of Relationship.



8
9
10
11
12
13
# File 'lib/pact_broker/domain/relationship.rb', line 8

def initialize consumer, provider, latest_pact = nil, latest_verification = nil
  @consumer = consumer
  @provider = provider
  @latest_pact = latest_pact
  @latest_verification = latest_verification
end

Instance Attribute Details

#consumerObject (readonly)

Returns the value of attribute consumer.



6
7
8
# File 'lib/pact_broker/domain/relationship.rb', line 6

def consumer
  @consumer
end

#providerObject (readonly)

Returns the value of attribute provider.



6
7
8
# File 'lib/pact_broker/domain/relationship.rb', line 6

def provider
  @provider
end

Class Method Details

.create(consumer, provider, latest_pact, latest_verification) ⇒ Object



15
16
17
# File 'lib/pact_broker/domain/relationship.rb', line 15

def self.create consumer, provider, latest_pact, latest_verification
  new consumer, provider, latest_pact, latest_verification
end

Instance Method Details

#<=>(other) ⇒ Object



72
73
74
75
76
# File 'lib/pact_broker/domain/relationship.rb', line 72

def <=> other
  comp = consumer_name <=> other.consumer_name
  return comp unless comp == 0
  provider_name <=> other.provider_name
end

#==(other) ⇒ Object



24
25
26
# File 'lib/pact_broker/domain/relationship.rb', line 24

def == other
  eq?(other)
end

#connected?(other) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/pact_broker/domain/relationship.rb', line 64

def connected? other
  include?(other.consumer) || include?(other.provider)
end

#consumer_nameObject



28
29
30
# File 'lib/pact_broker/domain/relationship.rb', line 28

def consumer_name
  consumer.name
end

#eq?(other) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/pact_broker/domain/relationship.rb', line 19

def eq? other
  Relationship === other && other.consumer == consumer && other.provider == provider &&
    other.latest_pact == latest_pact && other.latest_verification == latest_verification
end

#ever_verified?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/pact_broker/domain/relationship.rb', line 40

def ever_verified?
  !!latest_verification
end

#include?(pacticipant) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/pact_broker/domain/relationship.rb', line 68

def include? pacticipant
  pacticipant.id == consumer.id || pacticipant.id == provider.id
end

#latest_pactObject



36
37
38
# File 'lib/pact_broker/domain/relationship.rb', line 36

def latest_pact
  @latest_pact
end

#latest_verificationObject



44
45
46
# File 'lib/pact_broker/domain/relationship.rb', line 44

def latest_verification
  @latest_verification
end

#latest_verification_provider_versionObject



56
57
58
# File 'lib/pact_broker/domain/relationship.rb', line 56

def latest_verification_provider_version
  latest_verification.provider_version
end

#latest_verification_successful?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/pact_broker/domain/relationship.rb', line 48

def latest_verification_successful?
  latest_verification.success
end

#pact_changed_since_last_verification?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/pact_broker/domain/relationship.rb', line 52

def pact_changed_since_last_verification?
  latest_verification.pact_version_sha != latest_pact.pact_version_sha
end

#pacticipantsObject



60
61
62
# File 'lib/pact_broker/domain/relationship.rb', line 60

def pacticipants
  [consumer, provider]
end

#provider_nameObject



32
33
34
# File 'lib/pact_broker/domain/relationship.rb', line 32

def provider_name
  provider.name
end

#to_aObject



82
83
84
# File 'lib/pact_broker/domain/relationship.rb', line 82

def to_a
  [consumer, provider]
end

#to_sObject



78
79
80
# File 'lib/pact_broker/domain/relationship.rb', line 78

def to_s
  "Relationship between #{consumer_name} and #{provider_name}"
end