Sha256: 052468f53ae36c1b12232332f9bb0ca31e1bb5bd53f1b57c77004c8e047c441c
Contents?: true
Size: 1.37 KB
Versions: 11
Compression:
Stored size: 1.37 KB
Contents
require 'sequel' require 'pact_broker/domain/pacticipant' require 'pact_broker/repositories/helpers' module PactBroker module Pacticipants class Repository include PactBroker::Repositories::Helpers def find_by_name name PactBroker::Domain::Pacticipant.where(name_like(:name, name)).single_record end def find_by_id id PactBroker::Domain::Pacticipant.where(id: id).single_record end def find_all PactBroker::Domain::Pacticipant.order(:name).all end def find_all_pacticipant_versions name PactBroker::Domain::Version .select(:versions__id, :versions__number, :versions__pacticipant_id, :versions__order, :versions__created_at, :versions__updated_at) .join(:pacticipants, {id: :pacticipant_id}) .where(name_like(:name, name)) end def find_by_name_or_create name if pacticipant = find_by_name(name) pacticipant else create name: name end end def create args PactBroker::Domain::Pacticipant.new(name: args[:name], repository_url: args[:repository_url]).save(raise_on_save_failure: true) end def pacticipant_names PactBroker::Domain::Pacticipant.select(:name).order(:name).collect{ | pacticipant| pacticipant.name } end def find_latest_version name end end end end
Version data entries
11 entries across 11 versions & 1 rubygems