summaryrefslogtreecommitdiff
path: root/app/services/notes/update_service.rb
blob: 75a4b3ed8264f496e82a2f7bedaf30953d013516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Notes
  class UpdateService < BaseService
    def execute(note)
      return note unless note.editable?

      note.update_attributes(params.merge(updated_by: current_user))
      note.create_new_cross_references!(current_user)

      if note.previous_changes.include?('note')
        TodoService.new.update_note(note, current_user)
      end

      note
    end
  end
end