-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcreate.rb
More file actions
27 lines (24 loc) · 790 Bytes
/
create.rb
File metadata and controls
27 lines (24 loc) · 790 Bytes
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
# frozen_string_literal: true
class Project
class Create
class << self
def call(project_hash:, current_user:)
response = OperationResponse.new
response[:project] = build_project(project_hash, current_user)
response[:project].save!
response
rescue StandardError => e
Sentry.capture_exception(e)
response[:error] = "Error creating project: #{e}"
response
end
private
def build_project(project_hash, current_user)
project_hash[:identifier] = PhraseIdentifier.generate unless current_user&.experience_cs_admin?
new_project = Project.new(project_hash.except(:components))
new_project.components.build(project_hash[:components])
new_project
end
end
end
end