debian-mirror-gitlab/app/services/user_preferences/update_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
526 B
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
module UserPreferences
class UpdateService < BaseService
def initialize(user, params = {})
@preferences = user.user_preference
@params = params.to_h.dup.with_indifferent_access
end
def execute
if @preferences.update(@params)
ServiceResponse.success(
message: 'Preference was updated',
payload: { preferences: @preferences })
else
ServiceResponse.error(message: 'Could not update preference')
end
end
end
end