2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Labels
|
|
|
|
class UpdateService < Labels::BaseService
|
|
|
|
def initialize(params = {})
|
2019-03-02 22:35:43 +05:30
|
|
|
@params = params.to_h.dup.with_indifferent_access
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
# returns the updated label
|
|
|
|
def execute(label)
|
2019-03-02 22:35:43 +05:30
|
|
|
params[:name] = params.delete(:new_name) if params.key?(:new_name)
|
2017-08-17 22:00:37 +05:30
|
|
|
params[:color] = convert_color_name_to_hex if params[:color].present?
|
|
|
|
|
|
|
|
label.update(params)
|
|
|
|
label
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|