Class: PactBroker::Domain::Relationship
- Inherits:
-
Object
- Object
- PactBroker::Domain::Relationship
- Defined in:
- lib/pact_broker/domain/relationship.rb
Instance Attribute Summary collapse
-
#consumer ⇒ Object
readonly
Returns the value of attribute consumer.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #connected?(other) ⇒ Boolean
- #consumer_name ⇒ Object
- #eq?(other) ⇒ Boolean
- #ever_verified? ⇒ Boolean
- #include?(pacticipant) ⇒ Boolean
-
#initialize(consumer, provider, latest_pact = nil, latest_verification = nil) ⇒ Relationship
constructor
A new instance of Relationship.
- #latest_pact ⇒ Object
- #latest_verification ⇒ Object
- #latest_verification_provider_version ⇒ Object
- #latest_verification_successful? ⇒ Boolean
- #pact_changed_since_last_verification? ⇒ Boolean
- #pacticipants ⇒ Object
- #provider_name ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
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
#consumer ⇒ Object (readonly)
Returns the value of attribute consumer.
6 7 8 |
# File 'lib/pact_broker/domain/relationship.rb', line 6 def consumer @consumer end |
#provider ⇒ Object (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
64 65 66 |
# File 'lib/pact_broker/domain/relationship.rb', line 64 def connected? other include?(other.consumer) || include?(other.provider) end |
#consumer_name ⇒ Object
28 29 30 |
# File 'lib/pact_broker/domain/relationship.rb', line 28 def consumer_name consumer.name end |
#eq?(other) ⇒ 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
40 41 42 |
# File 'lib/pact_broker/domain/relationship.rb', line 40 def ever_verified? !!latest_verification end |
#include?(pacticipant) ⇒ 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_pact ⇒ Object
36 37 38 |
# File 'lib/pact_broker/domain/relationship.rb', line 36 def latest_pact @latest_pact end |
#latest_verification ⇒ Object
44 45 46 |
# File 'lib/pact_broker/domain/relationship.rb', line 44 def latest_verification @latest_verification end |
#latest_verification_provider_version ⇒ Object
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
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
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 |
#pacticipants ⇒ Object
60 61 62 |
# File 'lib/pact_broker/domain/relationship.rb', line 60 def pacticipants [consumer, provider] end |
#provider_name ⇒ Object
32 33 34 |
# File 'lib/pact_broker/domain/relationship.rb', line 32 def provider_name provider.name end |
#to_a ⇒ Object
82 83 84 |
# File 'lib/pact_broker/domain/relationship.rb', line 82 def to_a [consumer, provider] end |
#to_s ⇒ Object
78 79 80 |
# File 'lib/pact_broker/domain/relationship.rb', line 78 def to_s "Relationship between #{consumer_name} and #{provider_name}" end |