Sha256: 0489be624b7e7f33ddee97f6853eac105c9d623d1c44d6479a0a5262ae593f57

Contents?: true

Size: 849 Bytes

Versions: 9

Compression:

Stored size: 849 Bytes

Contents

require 'sequel'
require 'pact_broker/models/version'

module PactBroker
  module Repositories
    class VersionRepository

      def find_by_pacticipant_id_and_number pacticipant_id, number
        PactBroker::Models::Version.where(number: number, pacticipant_id: pacticipant_id).single_record
      end

      def create args
        PactBroker.logger.info "Creating version #{args[:number]} for pacticipant_id=#{args[:pacticipant_id]}"
        PactBroker::Models::Version.new(number: args[:number], pacticipant_id: args[:pacticipant_id]).save
      end

      def find_by_pacticipant_id_and_number_or_create pacticipant_id, number
        if version = find_by_pacticipant_id_and_number(pacticipant_id, number)
          version
        else
          create(pacticipant_id: pacticipant_id, number: number)
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pact_broker-0.0.9 lib/pact_broker/repositories/version_repository.rb
pact_broker-0.0.8 lib/pact_broker/repositories/version_repository.rb
pact_broker-0.0.7 lib/pact_broker/repositories/version_repository.rb
pact_broker-0.0.6 lib/pact_broker/repositories/version_repository.rb
pact_broker-0.0.5 lib/pact_broker/repositories/version_repository.rb
pact_broker-0.0.4 lib/pact_broker/repositories/version_repository.rb
pact_broker-0.0.3 lib/pact_broker/repositories/version_repository.rb
pact_broker-0.0.2 lib/pact_broker/repositories/version_repository.rb
pact_broker-0.0.1 lib/pact_broker/repositories/version_repository.rb