Sha256: c6de1d8a7a6a987988e84adff36e9aa0a86bbe4a8d33211fa207af37aa219fa3

Contents?: true

Size: 1.22 KB

Versions: 26

Compression:

Stored size: 1.22 KB

Contents

require 'pact_broker/domain/pact'
require 'pact_broker/pacts/pact_version_content'

module PactBroker
  module Pacts

    class DatabaseModel < Sequel::Model(:pacts)

      set_primary_key :id
      associate(:many_to_one, :provider, :class => "PactBroker::Domain::Pacticipant", :key => :provider_id, :primary_key => :id)
      associate(:many_to_one, :consumer_version, :class => "PactBroker::Domain::Version", :key => :version_id, :primary_key => :id)
      associate(:many_to_one, :pact_version_content, :key => :pact_version_content_sha, :primary_key => :sha)

      DatabaseModel.plugin :timestamps, :update_on_create=>true

      def to_domain
        PactBroker::Domain::Pact.new(
          id: id,
          provider: provider,
          consumer: consumer_version.pacticipant,
          consumer_version_number: consumer_version.number,
          consumer_version: to_version_domain,
          json_content: pact_version_content.content,
          updated_at: updated_at,
          created_at: created_at
          )
      end

      def to_version_domain
        OpenStruct.new(number: consumer_version.number, pacticipant: consumer_version.pacticipant, tags: consumer_version.tags, order: consumer_version.order)
      end

    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
pact_broker-1.18.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.18.0.beta.1 lib/pact_broker/pacts/database_model.rb
pact_broker-1.17.2 lib/pact_broker/pacts/database_model.rb
pact_broker-1.17.1 lib/pact_broker/pacts/database_model.rb
pact_broker-1.17.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.16.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.15.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.14.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.13.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.12.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.11.2 lib/pact_broker/pacts/database_model.rb
pact_broker-1.11.1 lib/pact_broker/pacts/database_model.rb
pact_broker-1.11.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.10.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.9.3 lib/pact_broker/pacts/database_model.rb
pact_broker-1.9.2 lib/pact_broker/pacts/database_model.rb
pact_broker-1.9.1 lib/pact_broker/pacts/database_model.rb
pact_broker-1.9.0 lib/pact_broker/pacts/database_model.rb
pact_broker-1.9.0.rc1 lib/pact_broker/pacts/database_model.rb
pact_broker-1.8.1 lib/pact_broker/pacts/database_model.rb