Class: ModSpox::Database
- Inherits:
-
Object
- Object
- ModSpox::Database
- Defined in:
- lib/mod_spox/Database.rb
Class Method Summary collapse
- .cache ⇒ Object
- .cache=(cache) ⇒ Object
- .db ⇒ Object
- .db=(database) ⇒ Object
- .reconnect ⇒ Object
- .reset_connections ⇒ Object
- .type ⇒ Object
- .type=(type) ⇒ Object
Class Method Details
.cache ⇒ Object
20 21 22 |
# File 'lib/mod_spox/Database.rb', line 20 def Database.cache return Database.class_variable_defined?(:@@cache) ? @@cache : nil end |
.cache=(cache) ⇒ Object
15 16 17 18 |
# File 'lib/mod_spox/Database.rb', line 15 def Database.cache=(cache) @@cache = nil @@cache = cache end |
.db ⇒ Object
28 29 30 |
# File 'lib/mod_spox/Database.rb', line 28 def Database.db return Database.class_variable_defined?(:@@db) ? @@db : nil end |
.db=(database) ⇒ Object
5 6 7 8 |
# File 'lib/mod_spox/Database.rb', line 5 def Database.db=(database) @@db = nil @@db = database end |
.reconnect ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mod_spox/Database.rb', line 36 def Database.reconnect begin @@db.test_connection Logger.warn('Database connection appears to be active. Closing.') @@db.disconnect rescue Object => boom Logger.warn('Database connection does not appear to be active.') ensure Logger.warn('Reconnecting to database.') ModSpox.setup_adapter end end |
.reset_connections ⇒ Object
32 33 34 |
# File 'lib/mod_spox/Database.rb', line 32 def Database.reset_connections @@db.disconnect end |
.type ⇒ Object
24 25 26 |
# File 'lib/mod_spox/Database.rb', line 24 def Database.type return Database.class_variable_defined?(:@@type) ? @@type : nil end |
.type=(type) ⇒ Object
10 11 12 13 |
# File 'lib/mod_spox/Database.rb', line 10 def Database.type=(type) @@type = nil @@type = type end |