diff --git a/app/models/global_setting.rb b/app/models/global_setting.rb index 33535335d7c..fabc777690f 100644 --- a/app/models/global_setting.rb +++ b/app/models/global_setting.rb @@ -137,6 +137,14 @@ class GlobalSetting end end + def self.add_default(name, default) + unless self.respond_to? name + define_singleton_method(name) do + default + end + end + end + class BaseProvider def self.coerce(setting) return setting == "true" if setting == "true" || setting == "false" diff --git a/spec/models/global_setting_spec.rb b/spec/models/global_setting_spec.rb index c02b383a947..e3fd9a9f515 100644 --- a/spec/models/global_setting_spec.rb +++ b/spec/models/global_setting_spec.rb @@ -50,6 +50,20 @@ describe GlobalSetting do end end + describe '.add_default' do + after do + class <