Sha256: d3c39cb0a07d907a7fa37ff5575fdef7cd4cae568f3c626b477466f7b7e8a5ba

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

require 'pact_broker/repositories'

module PactBroker

  module Services
    class PacticipantService

      extend PactBroker::Repositories

      def self.find_all_pacticipants
        pacticipant_repository.find_all
      end

      def self.find_pacticipant_by_name name
        pacticipant_repository.find_by_name(name)
      end

      def self.find_pacticipant_repository_url_by_pacticipant_name name
        pacticipant = pacticipant_repository.find_by_name(name)
        if pacticipant && pacticipant.repository_url
          pacticipant.repository_url
        else
          nil
        end
      end

      def self.create_or_update_pacticipant params
        pacticipant = pacticipant_repository.find_by_name(params[:name])
        if pacticipant
          pacticipant.update(repository_url: params[:repository_url])
          return pacticipant, false
        else
          pacticipant = pacticipant_repository.create(name: params[:name], repository_url: params[:repository_url])
          return pacticipant, true
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pact_broker-0.0.9 lib/pact_broker/services/pacticipant_service.rb
pact_broker-0.0.8 lib/pact_broker/services/pacticipant_service.rb
pact_broker-0.0.7 lib/pact_broker/services/pacticipant_service.rb
pact_broker-0.0.6 lib/pact_broker/services/pacticipant_service.rb
pact_broker-0.0.5 lib/pact_broker/services/pacticipant_service.rb
pact_broker-0.0.4 lib/pact_broker/services/pacticipant_service.rb
pact_broker-0.0.3 lib/pact_broker/services/pacticipant_service.rb
pact_broker-0.0.2 lib/pact_broker/services/pacticipant_service.rb