Sha256: 572f680968a5f3bb9ad0502469d772bbe9073d36400c1a05f7d51272df4d7dcb

Contents?: true

Size: 984 Bytes

Versions: 7

Compression:

Stored size: 984 Bytes

Contents

require 'sequel'
require 'pact_broker/domain/pacticipant'

module PactBroker
  module Repositories
    class PacticipantRepository

      def find_by_name name
        PactBroker::Domain::Pacticipant.where(name: name).single_record
      end

      def find_by_id id
        PactBroker::Domain::Pacticipant.where(id: id).single_record
      end

      def find_all
        PactBroker::Domain::Pacticipant.order(:name).all
      end

      def find_by_name_or_create name
        if pacticipant = find_by_name(name)
          pacticipant
        else
          create name: name
        end
      end

      def create args
        PactBroker::Domain::Pacticipant.new(name: args[:name], repository_url: args[:repository_url]).save(raise_on_save_failure: true)
      end

      def pacticipant_names
        PactBroker::Domain::Pacticipant.select(:name).order(:name).collect{ | pacticipant| pacticipant.name }
      end

      def find_latest_version name

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pact_broker-1.8.1 lib/pact_broker/repositories/pacticipant_repository.rb
pact_broker-1.8.0 lib/pact_broker/repositories/pacticipant_repository.rb
pact_broker-1.7.0 lib/pact_broker/repositories/pacticipant_repository.rb
pact_broker-1.6.0 lib/pact_broker/repositories/pacticipant_repository.rb
pact_broker-1.5.0 lib/pact_broker/repositories/pacticipant_repository.rb
pact_broker-1.4.0 lib/pact_broker/repositories/pacticipant_repository.rb
pact_broker-1.3.2.rc1 lib/pact_broker/repositories/pacticipant_repository.rb