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
180
181
182
183
|
# File 'lib/ardb.rb', line 180
def self.mysql(config)
require "ardb/adapter/mysql"
Adapter::Mysql.new(config)
end
|
.mysql2(config) ⇒ Object
185
|
# File 'lib/ardb.rb', line 185
def self.mysql2(config); self.mysql(config); end
|
.new(config) ⇒ Object
159
160
161
162
163
164
|
# File 'lib/ardb.rb', line 159
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
178
|
# File 'lib/ardb.rb', line 178
def self.postgres(config); self.postgresql(config); end
|
.postgresql(config) ⇒ Object
173
174
175
176
|
# File 'lib/ardb.rb', line 173
def self.postgresql(config)
require "ardb/adapter/postgresql"
Adapter::Postgresql.new(config)
end
|
.sqlite(config) ⇒ Object
166
167
168
169
|
# File 'lib/ardb.rb', line 166
def self.sqlite(config)
require "ardb/adapter/sqlite"
Adapter::Sqlite.new(config)
end
|
.sqlite3(config) ⇒ Object
171
|
# File 'lib/ardb.rb', line 171
def self.sqlite3(config); self.sqlite(config); end
|