Sha256: fc189f4733910ba7577f54a8d3584240979a6b8b3ea5e3e56a40227f7295db0d

Contents?: true

Size: 1.01 KB

Versions: 115

Compression:

Stored size: 1.01 KB

Contents

require 'pact_broker/domain/label'
require 'pact_broker/repositories/helpers'

module PactBroker
  module Labels
    class Repository

      include PactBroker::Repositories::Helpers

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

      def find args
        PactBroker::Domain::Label
          .select(Sequel.qualify("labels", "name"), Sequel.qualify("labels", "pacticipant_id"), Sequel.qualify("labels", "created_at"), Sequel.qualify("labels", "updated_at"))
          .join(:pacticipants, {id: :pacticipant_id})
          .where(name_like(Sequel.qualify("labels", "name"), args.fetch(:label_name)))
          .where(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

115 entries across 115 versions & 1 rubygems

Version Path
pact_broker-2.23.3 lib/pact_broker/labels/repository.rb
pact_broker-2.23.2 lib/pact_broker/labels/repository.rb
pact_broker-2.23.1 lib/pact_broker/labels/repository.rb
pact_broker-2.23.0 lib/pact_broker/labels/repository.rb
pact_broker-2.22.0 lib/pact_broker/labels/repository.rb
pact_broker-2.21.0 lib/pact_broker/labels/repository.rb
pact_broker-2.20.0 lib/pact_broker/labels/repository.rb
pact_broker-2.19.2 lib/pact_broker/labels/repository.rb
pact_broker-2.19.1 lib/pact_broker/labels/repository.rb
pact_broker-2.19.0 lib/pact_broker/labels/repository.rb
pact_broker-2.18.0 lib/pact_broker/labels/repository.rb
pact_broker-2.17.1 lib/pact_broker/labels/repository.rb
pact_broker-2.17.0 lib/pact_broker/labels/repository.rb
pact_broker-2.16.1 lib/pact_broker/labels/repository.rb
pact_broker-2.16.0 lib/pact_broker/labels/repository.rb
pact_broker-2.15.0 lib/pact_broker/labels/repository.rb
pact_broker-2.14.0 lib/pact_broker/labels/repository.rb
pact_broker-2.13.1 lib/pact_broker/labels/repository.rb
pact_broker-2.13.0 lib/pact_broker/labels/repository.rb
pact_broker-2.12.0 lib/pact_broker/labels/repository.rb