Sha256: 73ffaa5f9ec12730cf68258bf95b8384a051a06dcb31b72f38ea9d916ff575fa

Contents?: true

Size: 986 Bytes

Versions: 6

Compression:

Stored size: 986 Bytes

Contents

require "pact_broker/domain/label"

module PactBroker
  module Labels
    class Repository

      def get_all_unique_labels pagination_options = {}
        PactBroker::Domain::Label.distinct.select(:name).all_with_pagination_options(pagination_options)
      end

      def create args
        Domain::Label.new(name: args.fetch(:name), pacticipant: args.fetch(:pacticipant)).save
      end

      def find args
        PactBroker::Domain::Label
          .select_all_qualified
          .join(:pacticipants, { id: :pacticipant_id })
          .where(Sequel.name_like(Sequel.qualify("labels", "name"), args.fetch(:label_name)))
          .where(Sequel.name_like(Sequel.qualify("pacticipants", "name"), args.fetch(:pacticipant_name)))
          .single_record
      end

      def delete args
        find(args).delete
      end

      def delete_by_pacticipant_id pacticipant_id
        Sequel::Model.db[:labels].where(pacticipant_id: pacticipant_id).delete
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pact_broker-2.114.0 lib/pact_broker/labels/repository.rb
pact_broker-2.113.2 lib/pact_broker/labels/repository.rb
pact_broker-2.113.1 lib/pact_broker/labels/repository.rb
pact_broker-2.113.0 lib/pact_broker/labels/repository.rb
pact_broker-2.112.0 lib/pact_broker/labels/repository.rb
pact_broker-2.111.0 lib/pact_broker/labels/repository.rb