class AppKonfig::Config
Constants
- CONFIG_PATH
- DEFAULT_ENV
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/app_konfig/config.rb, line 15 def initialize super deep_merge!(pub_config).deep_merge!(sec_config) end
Public Instance Methods
get(args)
click to toggle source
# File lib/app_konfig/config.rb, line 20 def get(args) args.split('.').inject(self) { |hash, arg| hash.fetch(arg) } rescue KeyError raise AppKonfig::ConfigurationKeyNotFound.new("configuration key not found") end
method_missing(key)
click to toggle source
# File lib/app_konfig/config.rb, line 26 def method_missing(key) key = key.to_s return self[key] unless self[key].is_a?(Hash) ::AppKonfig::Config[self[key]] end
Private Instance Methods
env()
click to toggle source
# File lib/app_konfig/config.rb, line 46 def env ENV.fetch('RAILS_ENV'){ DEFAULT_ENV } end
load_config(path)
click to toggle source
# File lib/app_konfig/config.rb, line 42 def load_config(path) YAML.load(ERB.new(File.read(path)).result).fetch(env) end
pub_config()
click to toggle source
# File lib/app_konfig/config.rb, line 34 def pub_config load_config(CONFIG_PATH[:public]) rescue {} end
sec_config()
click to toggle source
# File lib/app_konfig/config.rb, line 38 def sec_config load_config(CONFIG_PATH[:secret]) rescue {} end