Sha256: 83a19c625b108fd7c43556d44aec89cad82ae1881d0229775cbb6b5d1a26921f

Contents?: true

Size: 1.16 KB

Versions: 17

Compression:

Stored size: 1.16 KB

Contents

module PactBroker
  module Domain

    class Relationship

      attr_reader :consumer, :provider

      def initialize consumer, provider
        @consumer = consumer
        @provider = provider
      end

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

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

      def == other
        eq?(other)
      end

      def consumer_name
        consumer.name
      end

      def provider_name
        provider.name
      end

      def pacticipants
        [consumer, provider]
      end

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

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

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

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

      def to_a
        [consumer, provider]
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pact_broker-1.18.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.18.0.beta.1 lib/pact_broker/domain/relationship.rb
pact_broker-1.17.2 lib/pact_broker/domain/relationship.rb
pact_broker-1.17.1 lib/pact_broker/domain/relationship.rb
pact_broker-1.17.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.16.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.15.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.14.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.13.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.12.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.11.2 lib/pact_broker/domain/relationship.rb
pact_broker-1.11.1 lib/pact_broker/domain/relationship.rb
pact_broker-1.11.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.10.0 lib/pact_broker/domain/relationship.rb
pact_broker-1.9.3 lib/pact_broker/domain/relationship.rb
pact_broker-1.9.2 lib/pact_broker/domain/relationship.rb
pact_broker-1.9.1 lib/pact_broker/domain/relationship.rb