Module: App::Config
- Defined in:
- lib/app/app/config.rb
Defined Under Namespace
Modules: TreatSymbolsAsStrings
Constant Summary
collapse
- @@configurations =
{}
Class Method Summary
collapse
Class Method Details
34
35
36
37
38
39
40
41
|
# File 'lib/app/app/config.rb', line 34
def self.current
@@configurations[App.root] ||= begin
config = self.load
default_settings = config["default"] || {}
current_settings = config[App.env] || {}
default_settings.update current_settings
end.extend(TreatSymbolsAsStrings)
end
|
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/app/app/config.rb', line 21
def self.load
config = paths.inject(nil) do |c, path|
c || read(path)
end
config ||= begin
App.logger.warn "No configuration found in #{App.root}"
{}
end
end
|
9
10
11
|
# File 'lib/app/app/config.rb', line 9
def self.paths
[ "#{App.root}/config/app.yml", "#{App.root}/config.yml" ]
end
|
.read(path) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/app/app/config.rb', line 13
def self.read(path)
return unless File.exist?(path)
App.logger.info "Reading configuration from #{path}"
erb = File.read(path)
yaml = ERB.new(erb).result(binding)
YAML.load(yaml) || {}
end
|