Module: AppConfig
- Defined in:
- lib/app_config/base.rb,
lib/app_config/railtie.rb,
lib/app_config/version.rb,
lib/app_config/accessor_proxy.rb
Defined Under Namespace
Modules: VERSION
Classes: AccessorProxy, Railtie
Class Method Summary
collapse
Class Method Details
.[](key) ⇒ Object
17
18
19
|
# File 'lib/app_config/base.rb', line 17
def [](key)
return @@config[key]
end
|
.config_files ⇒ Object
21
22
23
|
# File 'lib/app_config/base.rb', line 21
def config_files
Dir[config_files_path.join('*appconfig.yml').to_s]
end
|
.get(key) ⇒ Object
25
26
27
|
# File 'lib/app_config/base.rb', line 25
def get(key)
return AppConfig[key]
end
|
.load_config_file(file_path) ⇒ Object
29
30
31
32
33
|
# File 'lib/app_config/base.rb', line 29
def load_config_file(file_path)
YAML::load(ERB.new((IO.read(file_path))).result).symbolize_keys
rescue Errno::ENOENT
{}
end
|
.method_missing(method, *args, &block) ⇒ Object
40
41
42
|
# File 'lib/app_config/base.rb', line 40
def method_missing(method, *args, &block)
@@config.send method, *args, &block
end
|
.reload! ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/app_config/base.rb', line 8
def reload!
set_default_paths if config_files_path.nil?
@@config = AccessorProxy.new(load_config_file(default_config_file_path))
config_files.each do |config_file|
@@config.merge!(load_config_file(config_file))
end
end
|
.set_default_paths ⇒ Object
35
36
37
38
|
# File 'lib/app_config/base.rb', line 35
def set_default_paths
self.config_files_path = ::Rails.root.join('config')
self.default_config_file_path = self.config_files_path.join('appconfig.defaults.yml')
end
|