gitlab-org--gitlab-foss/app/services/labels/update_service.rb

19 lines
448 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-03-29 07:45:15 -04:00
module Labels
class UpdateService < Labels::BaseService
def initialize(params = {})
@params = params.to_h.dup.with_indifferent_access
2017-03-29 07:45:15 -04:00
end
# returns the updated label
def execute(label)
2018-09-08 04:36:45 -04:00
params[:name] = params.delete(:new_name) if params.key?(:new_name)
2017-03-29 07:45:15 -04:00
params[:color] = convert_color_name_to_hex if params[:color].present?
label.update(params)
label
end
end
end