Class: AlertManagement::Alerts::UpdateService
- Inherits:
-
Object
- Object
- AlertManagement::Alerts::UpdateService
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/alert_management/alerts/update_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(alert, current_user, params) ⇒ UpdateService
constructor
A new instance of UpdateService.
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.
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
#execute ⇒ Object
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 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..to_sentence) end end |