Module: AppEnvConfig
- Defined in:
- lib/app_env_config.rb,
lib/app_env_config/version.rb,
lib/generators/app_env_config/install_generator.rb
Defined Under Namespace
Modules: Generators
Constant Summary collapse
- VERSION =
'0.1.2'- @@cache =
{}
Class Method Summary collapse
- .get(config_name, with_env = true) ⇒ Object
- .root_path ⇒ Object
- .uncached(config_name, with_env = true) ⇒ Object
Class Method Details
.get(config_name, with_env = true) ⇒ Object
12 13 14 15 |
# File 'lib/app_env_config.rb', line 12 def get(config_name, with_env = true) @@cache[config_name] ||= {} @@cache[config_name][with_env] ||= uncached(config_name, with_env) end |
.root_path ⇒ Object
7 8 9 10 |
# File 'lib/app_env_config.rb', line 7 def root_path # ENV['BUNDLE_GEMFILE'].gsub(/\/Gemfile\z/, '') Rails.root || Pathname.new(ENV['RAILS_ROOT'] || Dir.pwd) end |
.uncached(config_name, with_env = true) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/app_env_config.rb', line 17 def uncached(config_name, with_env = true) hash = YAML.load(ERB.new(File.read([root_path, 'config', "#{config_name}.yml"].join('/'))).result) default = hash && hash['default'] || {} hash = hash[Rails.env] if with_env && hash (hash ? default.deep_merge(hash) : default).with_indifferent_access end |