blob: 05b0b8e9fa6bf43011d83ff00c0292995c1b85f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# frozen_string_literal: true
module Packages
class CreatePackageService < BaseService
protected
def find_or_create_package!(package_type, name: params[:name], version: params[:version])
project
.packages
.with_package_type(package_type)
.safe_find_or_create_by!(name: name, version: version)
end
def create_package!(package_type, attrs = {})
project
.packages
.with_package_type(package_type)
.create!(package_attrs(attrs))
end
private
def package_attrs(attrs)
{
name: params[:name],
version: params[:version]
}.merge(attrs)
end
end
end
|