Module: EacRailsBase0App::Application::Envvars::ClassMethods
- Defined in:
- lib/eac_rails_base0/app_base/application/envvars.rb
Instance Method Summary collapse
- #config_root ⇒ Object
- #envvars_files ⇒ Object
- #load_envvars_file(path) ⇒ Object
- #setup_envvars ⇒ Object
Instance Method Details
#config_root ⇒ Object
18 19 20 |
# File 'lib/eac_rails_base0/app_base/application/envvars.rb', line 18 def config_root ::Rails.root.join('config') end |
#envvars_files ⇒ Object
22 23 24 25 26 27 |
# File 'lib/eac_rails_base0/app_base/application/envvars.rb', line 22 def envvars_files ENVVARS_FILE_EXTENSIONS.flat_map do |extension| [config_root.join("#{ENVVARS_FILE_BASENAME}#{extension}")] + config_root.join(ENVVARS_DIRECTORY_NAME).glob("*#{extension}") end end |
#load_envvars_file(path) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/eac_rails_base0/app_base/application/envvars.rb', line 29 def load_envvars_file(path) return unless path.exist? vars = ::EacRubyUtils::Yaml.load(path.read) raise "\"#{path}\" does not contain a Hash" unless vars.is_a?(::Hash) vars.each { |name, value| ENV[name.to_s] = value.to_s } end |
#setup_envvars ⇒ Object
38 39 40 |
# File 'lib/eac_rails_base0/app_base/application/envvars.rb', line 38 def setup_envvars envvars_files.each { |path| load_envvars_file(path) } end |