require 'singleton' module Ki # named conf because ruby has Config class :( # in version 2 Config class will be deprecated and # replace with RbConfig # When you update to ruby2, think about changing the name class Conf include Singleton attr_accessor :yaml def initialize super config_path = File.join(Dir.pwd, 'config.yml') if File.exists? config_path @yaml = YAML.load_file(config_path) else @yaml = YAML.load({ 'database_host' => '127.0.0.1', 'database_port' => 27017, 'database_name' => 'ki_default_db' }.to_yaml) end end end end