Sha256: 4b5fc1e5781004b8f3e656a8fd0d4cd828f7b9464fab5f09b952c4dc19f3c1d7
Contents?: true
Size: 1.46 KB
Versions: 39
Compression:
Stored size: 1.46 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 find end 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]).all end 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 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 end end end
Version data entries
39 entries across 39 versions & 1 rubygems