Class: PactBroker::Labels::Repository
Instance Method Summary
collapse
#case_sensitivity_options, #mysql?, #name_like, #order_ignore_case, #postgres?, #select_all_qualified, #select_for_subquery, #upsert
Instance Method Details
#create(args) ⇒ Object
10
11
12
|
# File 'lib/pact_broker/labels/repository.rb', line 10
def create args
Domain::Label.new(name: args.fetch(:name), pacticipant: args.fetch(:pacticipant)).save
end
|
#delete(args) ⇒ Object
23
24
25
|
# File 'lib/pact_broker/labels/repository.rb', line 23
def delete args
find(args).delete
end
|
#delete_by_pacticipant_id(pacticipant_id) ⇒ Object
27
28
29
|
# File 'lib/pact_broker/labels/repository.rb', line 27
def delete_by_pacticipant_id pacticipant_id
Sequel::Model.db[:labels].where(pacticipant_id: pacticipant_id).delete
end
|
#find(args) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/pact_broker/labels/repository.rb', line 14
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
|