Class: PactBroker::Pacticipants::Repository

Inherits:
Object
  • Object
show all
Includes:
Repositories::Helpers
Defined in:
lib/pact_broker/pacticipants/repository.rb

Instance Method Summary collapse

Methods included from Repositories::Helpers

#case_sensitivity_options, #mysql?, #name_like, #order_ignore_case, #select_for_subquery

Instance Method Details

#create(args) ⇒ Object



39
40
41
# File 'lib/pact_broker/pacticipants/repository.rb', line 39

def create args
  PactBroker::Domain::Pacticipant.new(name: args[:name], repository_url: args[:repository_url]).save(raise_on_save_failure: true)
end

#find_allObject



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

def find_all
  PactBroker::Domain::Pacticipant.order(:name).all
end

#find_all_pacticipant_versions_in_reverse_order(name) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/pact_broker/pacticipants/repository.rb', line 23

def find_all_pacticipant_versions_in_reverse_order name
  PactBroker::Domain::Version
    .select(Sequel[:versions][:id], Sequel[:versions][:number], Sequel[:versions][:pacticipant_id], Sequel[:versions][:order], Sequel[:versions][:created_at], Sequel[:versions][:updated_at])
    .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



31
32
33
34
35
36
37
# File 'lib/pact_broker/pacticipants/repository.rb', line 31

def find_by_name_or_create name
  if pacticipant = find_by_name(name)
    pacticipant
  else
    create name: name
  end
end

#find_latest_version(name) ⇒ Object



47
48
49
# File 'lib/pact_broker/pacticipants/repository.rb', line 47

def find_latest_version name

end

#pacticipant_namesObject



43
44
45
# File 'lib/pact_broker/pacticipants/repository.rb', line 43

def pacticipant_names
  PactBroker::Domain::Pacticipant.select(:name).order(:name).collect{ | pacticipant| pacticipant.name }
end