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