mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 14:45:56 +08:00
Implement loading settings from both, database and env variables [SCI-8813] (#5885)
This commit is contained in:
parent
2680b317e5
commit
4a563d3456
|
@ -1,4 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationSettings < Settings
|
||||
def load_values_from_env
|
||||
ENV.select { |name, _| name =~ /^APP_STTG_[A-Z0-9_]*/ }.transform_keys(&:downcase)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,4 +4,16 @@ class Settings < ApplicationRecord
|
|||
def self.instance
|
||||
first || new
|
||||
end
|
||||
|
||||
def values
|
||||
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))
|
||||
end
|
||||
merged_values
|
||||
end
|
||||
|
||||
def load_values_from_env
|
||||
raise NotImplementedError
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue