Module: Rivendell::DB
- Defined in:
- lib/rivendell/db.rb,
lib/rivendell/db/version.rb
Overview
DataMapper::Logger.new(STDOUT, :debug) DataMapper::Model.raise_on_save_failure = true
Defined Under Namespace
Classes: Cart, Cut, Dropbox, Group
Constant Summary
collapse
- VERSION =
"0.2"
Class Method Summary
collapse
Class Method Details
.default_url ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/rivendell/db.rb', line 19
def self.default_url
if mysql_conf
"mysql://#{mysql_conf['Loginname']}:#{mysql_conf['Password']}@#{mysql_conf['Hostname']}/#{mysql_conf['Database']}"
else
'mysql://rduser:letmein@localhost/Rivendell'
end
end
|
.establish_connection(url = default_url) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/rivendell/db.rb', line 28
def self.establish_connection(url = default_url)
DataMapper.setup :default, url
DataMapper.repository(:default).adapter.field_naming_convention =
DataMapper::NamingConventions::Field::Underscored
true
end
|
.mysql_conf ⇒ Object
15
16
17
|
# File 'lib/rivendell/db.rb', line 15
def self.mysql_conf
@mysql_conf ||= IniFile.load("/etc/rd.conf")['mySQL'] if File.exists?("/etc/rc.conf")
end
|