From 9c622d0b7cdd2cd86a80e30c3d367dedc334d5ac Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Tue, 2 Jul 2024 16:35:23 +0200 Subject: [PATCH] simplify the implementation of order of precedence for meta_server-tag overrides/defaults --- app/controllers/concerns/api_helper.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/concerns/api_helper.rb b/app/controllers/concerns/api_helper.rb index 627ea186..e948704d 100644 --- a/app/controllers/concerns/api_helper.rb +++ b/app/controllers/concerns/api_helper.rb @@ -248,9 +248,11 @@ def apply_config_server_tag(params) override = Rails.configuration.x.override_create_params default_tenant, override_tenant = TenantSetting.defaults_and_overrides(@tenant&.id) - params[:'meta_server-tag'] = default_tenant[:'meta_server-tag'] if params[:'meta_server-tag'].nil? && !default_tenant[:'meta_server-tag'].nil? - params[:'meta_server-tag'] = default[:'meta_server-tag'] if params[:'meta_server-tag'].nil? && !default[:'meta_server-tag'].nil? - params[:'meta_server-tag'] = override[:'meta_server-tag'] unless override[:'meta_server-tag'].nil? - params[:'meta_server-tag'] = override_tenant[:'meta_server-tag'] unless override_tenant[:'meta_server-tag'].nil? + params[:'meta_server-tag'] = + override_tenant[:'meta_server-tag'].presence || + override[:'meta_server-tag'].presence || + params[:'meta_server-tag'].presence || + default_tenant[:'meta_server-tag'].presence || + default[:'meta_server-tag'].presence end end