Module: Ardb::Adapter
- Defined in:
- lib/ardb.rb,
lib/ardb/adapter/base.rb,
lib/ardb/adapter/mysql.rb,
lib/ardb/adapter/sqlite.rb,
lib/ardb/adapter/postgresql.rb
Defined Under Namespace
Classes: Base, Mysql, Postgresql, Sqlite
Constant Summary
collapse
- VALID_ADAPTERS =
[
'sqlite',
'sqlite3',
'postgresql',
'postgres',
'mysql',
'mysql2'
].freeze
Class Method Summary
collapse
Class Method Details
.mysql(config) ⇒ Object
177
178
179
180
|
# File 'lib/ardb.rb', line 177
def self.mysql(config)
require 'ardb/adapter/mysql'
Adapter::Mysql.new(config)
end
|
.mysql2(config) ⇒ Object
182
|
# File 'lib/ardb.rb', line 182
def self.mysql2(config); self.mysql(config); end
|
.new(config) ⇒ Object
156
157
158
159
160
161
|
# File 'lib/ardb.rb', line 156
def self.new(config)
if !VALID_ADAPTERS.include?(config.adapter)
raise InvalidAdapterError, "invalid adapter: `#{config.adapter}`"
end
self.send(config.adapter, config)
end
|
.postgres(config) ⇒ Object
175
|
# File 'lib/ardb.rb', line 175
def self.postgres(config); self.postgresql(config); end
|
.postgresql(config) ⇒ Object
170
171
172
173
|
# File 'lib/ardb.rb', line 170
def self.postgresql(config)
require 'ardb/adapter/postgresql'
Adapter::Postgresql.new(config)
end
|
.sqlite(config) ⇒ Object
163
164
165
166
|
# File 'lib/ardb.rb', line 163
def self.sqlite(config)
require 'ardb/adapter/sqlite'
Adapter::Sqlite.new(config)
end
|
.sqlite3(config) ⇒ Object
168
|
# File 'lib/ardb.rb', line 168
def self.sqlite3(config); self.sqlite(config); end
|