Class: PactBroker::Repositories::PacticipantRepository

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/pact_broker/repositories/pacticipant_repository.rb

Instance Method Summary collapse

Methods included from Helpers

#case_sensitivity_options, #name_like

Instance Method Details

#create(args) ⇒ Object



31
32
33
# File 'lib/pact_broker/repositories/pacticipant_repository.rb', line 31

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/repositories/pacticipant_repository.rb', line 19

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

#find_by_id(id) ⇒ Object



15
16
17
# File 'lib/pact_broker/repositories/pacticipant_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/repositories/pacticipant_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



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

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



39
40
41
# File 'lib/pact_broker/repositories/pacticipant_repository.rb', line 39

def find_latest_version name

end

#pacticipant_namesObject



35
36
37
# File 'lib/pact_broker/repositories/pacticipant_repository.rb', line 35

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