Class: DesignManagement::CopyDesignCollection::QueueService

Inherits:
Object
  • Object
show all
Defined in:
app/services/design_management/copy_design_collection/queue_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user, issue, target_issue) ⇒ QueueService

Returns a new instance of QueueService.


8
9
10
11
12
13
# File 'app/services/design_management/copy_design_collection/queue_service.rb', line 8

def initialize(current_user, issue, target_issue)
  @current_user = current_user
  @issue = issue
  @target_issue = target_issue
  @target_design_collection = target_issue.design_collection
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
23
24
# File 'app/services/design_management/copy_design_collection/queue_service.rb', line 15

def execute
  return error('User cannot copy designs to issue') unless user_can_copy?
  return error('Target design collection copy state must be `ready`') unless target_design_collection.can_start_copy?

  target_design_collection.start_copy!

  DesignManagement::CopyDesignCollectionWorker.perform_async(current_user.id, issue.id, target_issue.id)

  ServiceResponse.success
end