I am taking a look at a legacy code base and I found this inside app/lib/app_configs.rb:
class AppConfigs CONFIG_ROOT = File.join(Rails.root, 'config', 'app_configs')
def self.[](file)
path = File.join(CONFIG_ROOT, "#{file}.yml")
config = YAML.load(ERB.new(File.new(path).read).result)
raise NotImplementedError if !config
HashWithIndifferentAccess.new config[Rails.env]
end
end
So,
-
app/lib is in the Ruby load path right?
-
what does self. do?
-
What does this method do? What does YAML.load and ERB.new do?
-
I found code that looks like this:
AppConfigs[:fog][:fog_directory]
What is that?
I do have a config/app_configs/fog.yml file that looks like this:
...
test:
fog_credentials:
<<: *default_fog_credentials
scheme: 'http'
host: 'localhost'
port: 5000
fog_directory: '/[path to uploads]'
asset_host: "//[something on cloudfront"
...
Aucun commentaire:
Enregistrer un commentaire