Class: PactBroker::Labels::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/labels/repository.rb

Instance Method Summary collapse

Instance Method Details

#create(args) ⇒ Object



6
7
8
# File 'lib/pact_broker/labels/repository.rb', line 6

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

#delete(args) ⇒ Object



19
20
21
# File 'lib/pact_broker/labels/repository.rb', line 19

def delete args
  find(args).delete
end

#delete_by_pacticipant_id(pacticipant_id) ⇒ Object



23
24
25
# File 'lib/pact_broker/labels/repository.rb', line 23

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

#find(args) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/pact_broker/labels/repository.rb', line 10

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