Class: Openbox::Database
- Inherits:
-
Object
- Object
- Openbox::Database
- Defined in:
- lib/openbox/database.rb
Overview
The database helper
Constant Summary collapse
- ADAPTERS =
Supported adpaters
%w[pg mysql2].freeze
Instance Method Summary collapse
-
#adapters ⇒ Array<String>
Get all database adapters.
-
#ensure_connection! ⇒ Object
Ensure database connection.
Instance Method Details
#adapters ⇒ Array<String>
Get all database adapters
19 20 21 22 |
# File 'lib/openbox/database.rb', line 19 def adapters @adapters ||= Openbox.runtime.select(*ADAPTERS).map(&:name) end |
#ensure_connection! ⇒ Object
Ensure database connection
28 29 30 31 32 33 34 35 36 |
# File 'lib/openbox/database.rb', line 28 def ensure_connection! return unless Openbox.runtime.has?(*ADAPTERS) puts 'Check database connection...' send("connect_#{adapters.first}") rescue Timeout::Error puts 'Unable connect database' exit 1 end |