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.11.0 lib/pact_broker/labels/repository.rb
pact_broker-2.10.0 lib/pact_broker/labels/repository.rb
pact_broker-2.9.0 lib/pact_broker/labels/repository.rb
pact_broker-2.9.0.beta.5 lib/pact_broker/labels/repository.rb
pact_broker-2.8.0.beta.5 lib/pact_broker/labels/repository.rb
pact_broker-2.8.0.beta.4 lib/pact_broker/labels/repository.rb
pact_broker-2.7.0.beta.3 lib/pact_broker/labels/repository.rb
pact_broker-2.7.0.beta.2 lib/pact_broker/labels/repository.rb
pact_broker-2.7.0.beta.1 lib/pact_broker/labels/repository.rb
pact_broker-2.6.0 lib/pact_broker/labels/repository.rb
pact_broker-2.5.1 lib/pact_broker/labels/repository.rb
pact_broker-2.5.0 lib/pact_broker/labels/repository.rb
pact_broker-2.4.2 lib/pact_broker/labels/repository.rb
pact_broker-2.4.1 lib/pact_broker/labels/repository.rb
pact_broker-2.4.0 lib/pact_broker/labels/repository.rb