Class: Baza
- Inherits:
-
Object
show all
- Defined in:
- lib/baza.rb
Defined Under Namespace
Modules: DatabaseModelFunctionality
Classes: BaseSqlDriver, Cloner, Column, Commands, Database, DatabaseModel, DatabaseModelName, Db, Dbtime, Driver, Dump, Errors, ForeignKey, Idquery, Index, JdbcDriver, JdbcResult, MysqlBaseDriver, QueryBuffer, ResultBase, Row, SqlQueries, Sqlspecs, Table, Tables
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.default_db ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/baza.rb', line 15
def self.default_db
unless @default_db
config_file = "#{Dir.pwd}/config/baza_database.rb"
init_file = "#{Dir.pwd}/config/initializers/baza_database.rb"
begin
load(config_file)
rescue LoadError
load(init_file)
end
unless @default_db.is_a?(Baza::Db)
raise "Config file didn't return a Baza::Db: #{@default_db.class.name}"
end
end
@default_db
end
|
Class Method Details
.drivers ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/baza.rb', line 34
def self.drivers
Enumerator.new do |yielder|
Dir.foreach("#{File.dirname(__FILE__)}/baza/driver") do |file|
if (match = file.match(/\A(.+?)\.rb\Z/))
load_driver(match[1])
driver_name = StringCases.snake_to_camel(match[1])
yielder << {
class: Baza::Driver.const_get(driver_name),
snake_name: match[1],
camel_name: driver_name
}
end
end
end
end
|
.load_driver(name) ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'lib/baza.rb', line 51
def self.load_driver(name)
require_relative "baza/driver/#{name}"
loads = %w(databases database tables table columns column indexes index result commands)
loads.each do |load|
file_path = "#{File.dirname(__FILE__)}/baza/driver/#{name}/#{load}"
require_relative file_path if File.exist?(file_path) || File.exist?("#{file_path}.rb")
end
end
|