Sha256: 020f12a07afc16d14924ee97f869edb8fabb87dedfb71974df4f32e16fbc8313

Contents?: true

Size: 813 Bytes

Versions: 3

Compression:

Stored size: 813 Bytes

Contents

require "pact_broker/domain/label"

module PactBroker
  module Labels
    class Repository
      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

3 entries across 3 versions & 1 rubygems

Version Path
pact_broker-2.109.1 lib/pact_broker/labels/repository.rb
pact_broker-2.109.0 lib/pact_broker/labels/repository.rb
pact_broker-2.108.0 lib/pact_broker/labels/repository.rb