Class: AlertManagement::Alerts::UpdateService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/alert_management/alerts/update_service.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(alert, current_user, params) ⇒ UpdateService

Returns a new instance of UpdateService.

Parameters:


11
12
13
14
15
16
# File 'app/services/alert_management/alerts/update_service.rb', line 11

def initialize(alert, current_user, params)
  @alert = alert
  @current_user = current_user
  @params = params
  @param_errors = []
end

Instance Method Details

#executeObject


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/services/alert_management/alerts/update_service.rb', line 18

def execute
  return error_no_permissions unless allowed?

  filter_params
  return error_invalid_params if param_errors.any?

  # Save old assignees for system notes
  old_assignees = alert.assignees.to_a

  if alert.update(params)
    handle_changes(old_assignees: old_assignees)

    success
  else
    error(alert.errors.full_messages.to_sentence)
  end
end