Fix update of database settings values [SCI-9240]

This commit is contained in:
Martin Artnik 2023-09-08 14:42:20 +02:00
parent cc1d179366
commit 18072bbde7

View file

@ -1,14 +1,18 @@
# frozen_string_literal: true
class Settings < ApplicationRecord
attr_accessor :merged_values
before_validation -> { self.values = merged_values || values }
def self.instance
first || new
end
def values
merged_values = super
self.merged_values ||= super
self.class.instance_methods(false).grep(/^load_values_from_[A-Z0-9_]*/).each do |method|
merged_values = merged_values.merge(public_send(method))
self.merged_values = self.merged_values.merge(public_send(method))
end
merged_values
end