lib/baza.rb in baza-0.0.15 vs lib/baza.rb in baza-0.0.16

- old
+ new

@@ -3,9 +3,27 @@ class Baza #Autoloader for subclasses. def self.const_missing(name) file_name = name.to_s.gsub(/(.)([A-Z])/,'\1_\2').downcase require "#{File.dirname(__FILE__)}/../include/#{file_name}.rb" - raise "Still not defined: '#{name}'." if !Baza.const_defined?(name) + raise "Still not defined: '#{name}'." unless Baza.const_defined?(name) return Baza.const_get(name) + end + + def self.default_db=(db) + @default_db = db + end + + def self.default_db + unless @default_db + config_file = "#{Dir.pwd}/config/baza_database.rb" + + load(config_file) + + unless @default_db.is_a?(Baza::Db) + raise "Config file didn't return a Baza::Db: #{@default_db.class.name}" + end + end + + return @default_db end end