module AppEnvConfig

Constants

VERSION

Public Class Methods

get(config_name, with_env = true) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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