Sha256: b3385485397ea41195865e2891f5f9ed4f2437666d42c8e4bbfa4ba181dcb0f3

Contents?: true

Size: 932 Bytes

Versions: 4

Compression:

Stored size: 932 Bytes

Contents

require 'sequel'

module PactBroker
  module Pacts
    class PactVersion < Sequel::Model(:pact_versions)
      one_to_many :pact_publications, :reciprocal => :pact_version

      def name
        "Pact between #{consumer_name} and #{provider_name}"
      end

      def provider_name
        pact_publications.last.provider.name
      end

      def consumer_name
        pact_publications.last.consumer.name
      end

      def latest_consumer_version
        consumer_versions.last
      end

      def latest_pact_publication
        latest_consumer_version.latest_pact_publication
      end

      def consumer_versions
        PactBroker::Domain::Version.where(id: PactBroker::Pacts::PactPublication.select(:consumer_version_id).where(pact_version_id: id)).order(:order)
      end

      def latest_consumer_version_number
        latest_consumer_version.number
      end
    end

    PactVersion.plugin :timestamps
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact_broker-2.0.0.beta.4 lib/pact_broker/pacts/pact_version.rb
pact_broker-2.0.0.beta.3 lib/pact_broker/pacts/pact_version.rb
pact_broker-2.0.0.beta.2 lib/pact_broker/pacts/pact_version.rb
pact_broker-2.0.0.beta.1 lib/pact_broker/pacts/pact_version.rb