Created
January 14, 2009 17:48
-
-
Save cloudhead/46983 to your computer and use it in GitHub Desktop.
This file contains 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
# | |
# Load configuration files | |
# | |
Dir.chdir('config') | |
Dir.new('.').entries.each do |path| | |
if ! File.directory? path and File.size? path | |
puts 'Loading ' + path + '...' | |
YAML.load_file( path ).each do |param, value| | |
Cloudder.config. | |
send( File.basename( path, '.yml' ) ). | |
send( param + '=', value ) | |
end | |
end | |
end | |
Dir.chdir( '../' ) | |
class Settings | |
def initialize | |
@children = {} | |
end | |
def has_key?( key ) | |
@children.has_key?( key ) | |
end | |
def respond_to?( path ) | |
true | |
end | |
def method_missing( path, value = nil ) | |
if ! value | |
@children[ path ] ||= Settings.new | |
elsif path.to_s =~ /=$/ | |
@children[ path.to_s[0..-2].intern ] = value | |
else | |
super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment