Sha256: 11f265fa37ce4562fe9e8dec958dd4283de255084c5692c15202d7eeace72017

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents

require 'wref'
require 'datet'
require 'string-cases'

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__)}/baza/#{file_name}.rb"
    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baza-0.0.19 lib/baza.rb
baza-0.0.18 lib/baza.rb