diff options
| author | Teddy Wing | 2017-04-29 20:14:51 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-04-29 20:14:51 +0200 | 
| commit | 1156010222a51643c7921aa953aad052e91b666c (patch) | |
| tree | 53cdd9f3a17585c618d6da52ba394164e10fa843 /lib | |
| parent | 3242a68312f54a226595df35b03d19927996b124 (diff) | |
| download | dbshell-rails-1156010222a51643c7921aa953aad052e91b666c.tar.bz2 | |
Add `DBShell::DatabaseClient`
A more generic interface to specific database adapter clients. This
class will act as a frontend to the others.
Calling its `.runshell()` will call the appropriate `.runshell()` for
the adapter provided in `connection_params`.
This way, we have a single entry point to start a database shell from
the Rake `dbshell` task.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dbshell/database_client.rb | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/lib/dbshell/database_client.rb b/lib/dbshell/database_client.rb new file mode 100644 index 0000000..8d55095 --- /dev/null +++ b/lib/dbshell/database_client.rb @@ -0,0 +1,15 @@ +class DBShell::DatabaseClient +  def self.handler(connection_params) +    case connection_params['adapter'] +    when 'sqlite3' +      DBShell::Sqlite3Client +    when 'postgresql' +      DBShell::PostgresClient +    else +      raise DBShell::InvalidDatabaseAdapter +    end +  end +end + + +class DBShell::InvalidDatabaseAdapter < StandardError; end | 
