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.79.1 lib/pact_broker/labels/repository.rb
pact_broker-2.79.0 lib/pact_broker/labels/repository.rb
pact_broker-2.78.1 lib/pact_broker/labels/repository.rb
pact_broker-2.78.0 lib/pact_broker/labels/repository.rb
pact_broker-2.77.0 lib/pact_broker/labels/repository.rb
pact_broker-2.76.2 lib/pact_broker/labels/repository.rb
pact_broker-2.76.1 lib/pact_broker/labels/repository.rb
pact_broker-2.76.0 lib/pact_broker/labels/repository.rb
pact_broker-2.75.0 lib/pact_broker/labels/repository.rb
pact_broker-2.74.1 lib/pact_broker/labels/repository.rb
pact_broker-2.74.0 lib/pact_broker/labels/repository.rb
pact_broker-2.73.0 lib/pact_broker/labels/repository.rb
pact_broker-2.72.0 lib/pact_broker/labels/repository.rb
pact_broker-2.71.0 lib/pact_broker/labels/repository.rb
pact_broker-2.70.0 lib/pact_broker/labels/repository.rb
pact_broker-2.69.0 lib/pact_broker/labels/repository.rb
pact_broker-2.68.1 lib/pact_broker/labels/repository.rb
pact_broker-2.68.0 lib/pact_broker/labels/repository.rb
pact_broker-2.67.0 lib/pact_broker/labels/repository.rb
pact_broker-2.66.0 lib/pact_broker/labels/repository.rb