Class: VsCode::Settings::CreateOrUpdateService
- Inherits:
-
Object
- Object
- VsCode::Settings::CreateOrUpdateService
- Includes:
- VsCode::Settings
- Defined in:
- app/services/vs_code/settings/create_or_update_service.rb
Constant Summary
Constants included from VsCode::Settings
DEFAULT_MACHINE, DEFAULT_SESSION, EXTENSIONS, NO_CONTENT_ETAG, SETTINGS_TYPES
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user:, params: {}) ⇒ CreateOrUpdateService
constructor
A new instance of CreateOrUpdateService.
Constructor Details
#initialize(current_user:, params: {}) ⇒ CreateOrUpdateService
Returns a new instance of CreateOrUpdateService.
8 9 10 11 12 |
# File 'app/services/vs_code/settings/create_or_update_service.rb', line 8 def initialize(current_user:, params: {}) @current_user = current_user @settings_context_hash = params.delete(:settings_context_hash) || nil @params = params end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/vs_code/settings/create_or_update_service.rb', line 14 def execute # The GitLab VSCode settings API does not support creating or updating # machines. return ServiceResponse.success(payload: DEFAULT_MACHINE) if params[:setting_type] == 'machines' setting = VsCodeSetting.by_user(current_user) additional_params = { uuid: SecureRandom.uuid } if params[:setting_type] == EXTENSIONS setting = setting.by_setting_types([EXTENSIONS], settings_context_hash).first additional_params[:settings_context_hash] = settings_context_hash else setting = setting.by_setting_types([params[:setting_type]]).first end create_or_update(setting: setting, additional_params: additional_params) end |