Class: Lotus::Model::Migrator::Connection Private
- Inherits:
-
Object
- Object
- Lotus::Model::Migrator::Connection
- Defined in:
- lib/lotus/model/migrator/connection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Sequel connection wrapper
Normalize external adapters interfaces
Instance Attribute Summary collapse
- #adapter_connection ⇒ Object readonly private
Instance Method Summary collapse
-
#database ⇒ Object
private
Returns DB name from conenction.
-
#database_type ⇒ Object
private
Returns DB type.
-
#global_uri ⇒ Object
private
Returns DB connection wihout specifying database name.
-
#host ⇒ Object
private
Returns DB connection host.
-
#initialize(adapter_connection) ⇒ Connection
constructor
private
A new instance of Connection.
-
#jdbc? ⇒ Boolean
private
Returns a boolean telling if a DB connection is from JDBC or not.
-
#parsed_uri ⇒ Object
private
Returns database connection URI instance without JDBC namespace.
-
#password ⇒ Object
private
Returns user from DB connection.
-
#port ⇒ Object
private
Returns DB connection port.
-
#uri ⇒ Object
private
Returns DB connection URI directly from adapter.
-
#user ⇒ Object
private
Returns user from DB connection.
Constructor Details
#initialize(adapter_connection) ⇒ Connection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Connection.
13 14 15 |
# File 'lib/lotus/model/migrator/connection.rb', line 13 def initialize(adapter_connection) @adapter_connection = adapter_connection end |
Instance Attribute Details
#adapter_connection ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/lotus/model/migrator/connection.rb', line 11 def adapter_connection @adapter_connection end |
Instance Method Details
#database ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns DB name from conenction
Even when adapter doesn’t provide it explicitly it tries to parse
43 44 45 |
# File 'lib/lotus/model/migrator/connection.rb', line 43 def database @database ||= opts.fetch(:database, parsed_uri.path[1..-1]) end |
#database_type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns DB type
55 56 57 |
# File 'lib/lotus/model/migrator/connection.rb', line 55 def database_type adapter_connection.database_type end |
#global_uri ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns DB connection wihout specifying database name
91 92 93 |
# File 'lib/lotus/model/migrator/connection.rb', line 91 def global_uri adapter_connection.uri.sub(parsed_uri.select(:path).first, '') end |
#host ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns DB connection host
Even when adapter doesn’t provide it explicitly it tries to parse
23 24 25 |
# File 'lib/lotus/model/migrator/connection.rb', line 23 def host @host ||= opts.fetch(:host, parsed_uri.host) end |
#jdbc? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean telling if a DB connection is from JDBC or not
99 100 101 |
# File 'lib/lotus/model/migrator/connection.rb', line 99 def jdbc? !adapter_connection.uri.scan('jdbc:').empty? end |
#parsed_uri ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns database connection URI instance without JDBC namespace
107 108 109 |
# File 'lib/lotus/model/migrator/connection.rb', line 107 def parsed_uri @uri ||= URI.parse(adapter_connection.uri.sub('jdbc:', '')) end |
#password ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns user from DB connection
Even when adapter doesn’t provide it explicitly it tries to parse
75 76 77 |
# File 'lib/lotus/model/migrator/connection.rb', line 75 def password @password ||= opts.fetch(:password, parsed_opt('password')) end |
#port ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns DB connection port
Even when adapter doesn’t provide it explicitly it tries to parse
33 34 35 |
# File 'lib/lotus/model/migrator/connection.rb', line 33 def port @port ||= opts.fetch(:port, parsed_uri.port) end |
#uri ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns DB connection URI directly from adapter
83 84 85 |
# File 'lib/lotus/model/migrator/connection.rb', line 83 def uri adapter_connection.uri end |
#user ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns user from DB connection
Even when adapter doesn’t provide it explicitly it tries to parse
65 66 67 |
# File 'lib/lotus/model/migrator/connection.rb', line 65 def user @user ||= opts.fetch(:user, parsed_opt('user')) end |