Class: Notes::CopyService

Inherits:
Object
  • Object
show all
Defined in:
app/services/notes/copy_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user, from_noteable, to_noteable) ⇒ CopyService

Returns a new instance of CopyService.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
# File 'app/services/notes/copy_service.rb', line 9

def initialize(current_user, from_noteable, to_noteable)
  raise ArgumentError, 'Noteables must be different' if from_noteable == to_noteable

  @current_user = current_user
  @from_noteable = from_noteable
  @to_noteable = to_noteable
  @from_project = from_noteable.project
  @new_discussion_ids = {}
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
# File 'app/services/notes/copy_service.rb', line 19

def execute
  from_noteable.notes_with_associations.find_each do |note|
    copy_note(note)
  end

  ServiceResponse.success
end