Created
October 12, 2009 22:18
-
-
Save Lytol/208803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
module Rails | |
module App | |
extend self | |
def [](key) | |
config[key] | |
end | |
def reload! | |
@config = nil | |
end | |
private | |
def config | |
@config ||= YAML::load(IO.read(File.join(Rails.root, "config/application.yml")))[Rails.env].symbolize_keys | |
end | |
def method_missing(sym, *args) | |
if config.has_key?(sym) && args.empty? | |
return config[sym] | |
else | |
super | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment