Sha256: 9ccacabecccf2aaf87b55a46eea36d69b8df59800e9ad9b785a7871e07ccc10d

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

require 'pact_broker/db'
require 'pact_broker/domain/order_versions'
require 'pact_broker/repositories/helpers'

module PactBroker

  module Domain

    class Version < Sequel::Model

      set_primary_key :id
      one_to_many :pact_publications, order: :revision_number, class: "PactBroker::Pacts::PactPublication", key: :consumer_version_id
      associate(:many_to_one, :pacticipant, :class => "PactBroker::Domain::Pacticipant", :key => :pacticipant_id, :primary_key => :id)
      one_to_many :tags, :reciprocal => :version, order: :created_at

      dataset_module do
        include PactBroker::Repositories::Helpers
      end

      def after_create
        OrderVersions.(self)
      end

      def to_s
        "Version: number=#{number}, pacticipant=#{pacticipant_id}"
      end

      def version_and_updated_date
        "Version #{number} - #{updated_at.to_time.localtime.strftime("%d/%m/%Y")}"
      end

      # What about provider??? This makes no sense
      def latest_pact_publication
        pact_publications.last
      end
    end

    Version.plugin :timestamps, :update_on_create=>true
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pact_broker-2.24.0 lib/pact_broker/domain/version.rb
pact_broker-2.23.4 lib/pact_broker/domain/version.rb
pact_broker-2.23.3 lib/pact_broker/domain/version.rb
pact_broker-2.23.2 lib/pact_broker/domain/version.rb
pact_broker-2.23.1 lib/pact_broker/domain/version.rb
pact_broker-2.23.0 lib/pact_broker/domain/version.rb
pact_broker-2.22.0 lib/pact_broker/domain/version.rb
pact_broker-2.21.0 lib/pact_broker/domain/version.rb