Class: Labels::UpdateService

Inherits:
BaseService show all
Defined in:
app/services/labels/update_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#convert_color_name_to_hex

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(params = {}) ⇒ UpdateService

Returns a new instance of UpdateService.



5
6
7
# File 'app/services/labels/update_service.rb', line 5

def initialize(params = {})
  @params = params.to_h.dup.with_indifferent_access
end

Instance Method Details

#execute(label) ⇒ Object

returns the updated label



10
11
12
13
14
15
16
17
# File 'app/services/labels/update_service.rb', line 10

def execute(label)
  params[:name] = params.delete(:new_name) if params.key?(:new_name)
  params[:color] = convert_color_name_to_hex if params[:color].present?
  params.delete(:lock_on_merge) unless allow_lock_on_merge?(label)

  label.update(params)
  label
end