Class: PactBroker::Pacticipants::Repository
- Inherits:
-
Object
- Object
- PactBroker::Pacticipants::Repository
show all
- Includes:
- Repositories::Helpers
- Defined in:
- lib/pact_broker/pacticipants/repository.rb
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
Need to be able to handle two calls that make the pacticipant at the same time. TODO raise error if attributes apart from name are different, because this indicates that the second request is not at the same time.
47
48
49
50
51
52
53
54
55
|
# File 'lib/pact_broker/pacticipants/repository.rb', line 47
def create args
PactBroker::Domain::Pacticipant.dataset.insert_ignore.insert(
name: args[:name],
repository_url: args[:repository_url],
created_at: Sequel.datetime_class.now,
updated_at: Sequel.datetime_class.now
)
PactBroker::Domain::Pacticipant.find(name: args[:name])
end
|
#delete_if_orphan(pacticipant) ⇒ Object
#find(options = {}) ⇒ Object
23
24
25
26
27
|
# File 'lib/pact_broker/pacticipants/repository.rb', line 23
def find options = {}
query = PactBroker::Domain::Pacticipant.select_all_qualified
query = query.label(options[:label_name]) if options[:label_name]
query.order_ignore_case(Sequel[:pacticipants][:name]).eager(:labels).eager(:latest_version).all
end
|
#find_all ⇒ Object
19
20
21
|
# File 'lib/pact_broker/pacticipants/repository.rb', line 19
def find_all
find
end
|
#find_all_pacticipant_versions_in_reverse_order(name) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/pact_broker/pacticipants/repository.rb', line 29
def find_all_pacticipant_versions_in_reverse_order name
PactBroker::Domain::Version.select_all_qualified
.join(:pacticipants, {id: :pacticipant_id})
.where(name_like(:name, name))
.reverse_order(:order)
end
|
#find_by_id(id) ⇒ Object
15
16
17
|
# File 'lib/pact_broker/pacticipants/repository.rb', line 15
def find_by_id id
PactBroker::Domain::Pacticipant.where(id: id).single_record
end
|
#find_by_name(name) ⇒ Object
11
12
13
|
# File 'lib/pact_broker/pacticipants/repository.rb', line 11
def find_by_name name
PactBroker::Domain::Pacticipant.where(name_like(:name, name)).single_record
end
|
#find_by_name_or_create(name) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/pact_broker/pacticipants/repository.rb', line 36
def find_by_name_or_create name
if pacticipant = find_by_name(name)
pacticipant
else
create name: name
end
end
|
#pacticipant_names ⇒ Object
57
58
59
|
# File 'lib/pact_broker/pacticipants/repository.rb', line 57
def pacticipant_names
PactBroker::Domain::Pacticipant.select(:name).order(:name).collect{ | pacticipant| pacticipant.name }
end
|