Class: Rails::Sequel::Database
- Inherits:
-
Object
- Object
- Rails::Sequel::Database
show all
- Defined in:
- lib/rails3_sequel/database.rb,
lib/rails3_sequel/adapters/mysql.rb,
lib/rails3_sequel/adapters/sqlite.rb,
lib/rails3_sequel/adapters/postgres.rb
Defined Under Namespace
Classes: Mysql, Postgres, Sqlite
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configurations ⇒ Object
Returns the value of attribute configurations.
6
7
8
|
# File 'lib/rails3_sequel/database.rb', line 6
def configurations
@configurations
end
|
Class Method Details
.adapter(env) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/rails3_sequel/database.rb', line 21
def adapter(env)
a = configurations[env]['adapter']
a_file = File.join(File.dirname(__FILE__), 'adapters', "#{a}.rb")
unless File.exists?(a_file)
raise "Adapter #{a} not supported."
end
load a_file
const_get(a.camelize.to_sym).new(env)
end
|
.connect(env, options = {}) ⇒ Object
35
36
37
|
# File 'lib/rails3_sequel/database.rb', line 35
def connect (env, options = {})
adapter(env).connect(options)
end
|
.create_all(options = {}) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/rails3_sequel/database.rb', line 43
def create_all (options = {})
for env,config in configurations do
next unless config['database']
create_database(env, options)
end
end
|
.create_database(env, options = {}) ⇒ Object
39
40
41
|
# File 'lib/rails3_sequel/database.rb', line 39
def create_database (env, options = {})
local_database?(env) { adapter(env).create_database(options) }
end
|
.drop_all ⇒ Object
54
55
56
57
58
59
|
# File 'lib/rails3_sequel/database.rb', line 54
def drop_all
for env,config in configurations do
next unless config['database']
drop_database(env)
end
end
|
.drop_database(env) ⇒ Object
50
51
52
|
# File 'lib/rails3_sequel/database.rb', line 50
def drop_database (env)
local_database?(env) { adapter(env).drop_database }
end
|