Skip to content

Instantly share code, notes, and snippets.

@cloudhead
Created January 14, 2009 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudhead/46983 to your computer and use it in GitHub Desktop.
Save cloudhead/46983 to your computer and use it in GitHub Desktop.
#
# 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