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
- #include?(pacticipant) ⇒ Boolean
-
#initialize(consumer, provider) ⇒ Relationship
constructor
A new instance of Relationship.
- #pacticipants ⇒ Object
- #provider_name ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(consumer, provider) ⇒ Relationship
Returns a new instance of Relationship.
8 9 10 11 |
# File 'lib/pact_broker/domain/relationship.rb', line 8 def initialize consumer, provider @consumer = consumer @provider = provider 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) ⇒ Object
13 14 15 |
# File 'lib/pact_broker/domain/relationship.rb', line 13 def self.create consumer, provider new consumer, provider end |
Instance Method Details
#<=>(other) ⇒ Object
45 46 47 48 49 |
# File 'lib/pact_broker/domain/relationship.rb', line 45 def <=> other comp = consumer_name <=> other.consumer_name return comp unless comp == 0 provider_name <=> other.provider_name end |
#==(other) ⇒ Object
21 22 23 |
# File 'lib/pact_broker/domain/relationship.rb', line 21 def == other eq?(other) end |
#connected?(other) ⇒ Boolean
37 38 39 |
# File 'lib/pact_broker/domain/relationship.rb', line 37 def connected? other include?(other.consumer) || include?(other.provider) end |
#consumer_name ⇒ Object
25 26 27 |
# File 'lib/pact_broker/domain/relationship.rb', line 25 def consumer_name consumer.name end |
#eq?(other) ⇒ Boolean
17 18 19 |
# File 'lib/pact_broker/domain/relationship.rb', line 17 def eq? other Relationship === other && other.consumer == consumer && other.provider == provider end |
#include?(pacticipant) ⇒ Boolean
41 42 43 |
# File 'lib/pact_broker/domain/relationship.rb', line 41 def include? pacticipant pacticipant.id == consumer.id || pacticipant.id == provider.id end |
#pacticipants ⇒ Object
33 34 35 |
# File 'lib/pact_broker/domain/relationship.rb', line 33 def pacticipants [consumer, provider] end |
#provider_name ⇒ Object
29 30 31 |
# File 'lib/pact_broker/domain/relationship.rb', line 29 def provider_name provider.name end |
#to_a ⇒ Object
55 56 57 |
# File 'lib/pact_broker/domain/relationship.rb', line 55 def to_a [consumer, provider] end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/pact_broker/domain/relationship.rb', line 51 def to_s "Relationship between #{consumer_name} and #{provider_name}" end |