Sha256: 78c9b6d00737ab2580e256b87d097a4a7be80ea4b453d6cb482878676ef69733
Contents?: true
Size: 886 Bytes
Versions: 1
Compression:
Stored size: 886 Bytes
Contents
require 'yaml' module LocalConfig def self.load_config(name, options={}) environment = options.has_key?(:environment) ? options[:environment] : true personal_config_file = "#{RAILS_ROOT}/config/#{name}.local.yml" shared_config_file = "#{RAILS_ROOT}/config/#{name}.yml" config_file = File.exists?(personal_config_file) ? personal_config_file : shared_config_file yaml = YAML.load(File.read(config_file)) if yaml.is_a? Hash config = HashWithIndifferentAccess.new yaml if environment log "WARNING: LocalConfig loaded an empty configuration for #{name}. Maybe you want to use :environment => false?" if config[RAILS_ENV].nil? config[RAILS_ENV] else config end else yaml end end def self.log(message) warn message if defined?(Rails) Rails.logger.warn message end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
webmat-local_config-0.2.1 | lib/local_config.rb |