Class: PactBroker::Repositories::PacticipantRepository

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

Instance Method Summary collapse

Instance Method Details

#create(args) ⇒ Object



28
29
30
# File 'lib/pact_broker/repositories/pacticipant_repository.rb', line 28

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

#find_allObject



16
17
18
# File 'lib/pact_broker/repositories/pacticipant_repository.rb', line 16

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

#find_by_id(id) ⇒ Object



12
13
14
# File 'lib/pact_broker/repositories/pacticipant_repository.rb', line 12

def find_by_id id
  PactBroker::Models::Pacticipant.where(id: id).single_record
end

#find_by_name(name) ⇒ Object



8
9
10
# File 'lib/pact_broker/repositories/pacticipant_repository.rb', line 8

def find_by_name name
  PactBroker::Models::Pacticipant.where(name: name).single_record
end

#find_by_name_or_create(name) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/pact_broker/repositories/pacticipant_repository.rb', line 20

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



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

def find_latest_version name

end

#pacticipant_namesObject



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

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