Class: MysqlConnection
- Inherits:
-
Object
- Object
- MysqlConnection
- Defined in:
- lib/database_fork/mysql_connection.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ MysqlConnection
constructor
A new instance of MysqlConnection.
- #params ⇒ Object
Constructor Details
#initialize(config) ⇒ MysqlConnection
Returns a new instance of MysqlConnection.
2 3 4 |
# File 'lib/database_fork/mysql_connection.rb', line 2 def initialize(config) @config = config end |
Instance Method Details
#params ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/database_fork/mysql_connection.rb', line 6 def params key_mapping = { 'username' => 'user', 'password' => 'password', 'socket' => 'socket', 'host' => 'host', 'port' => 'port' } @config.inject(Hash.new) do |akk, tupel| key, value = *tupel akk[key_mapping[key.to_s]] = value if key_mapping.key?(key.to_s) akk end.map do |tupel| key, value = *tupel "--#{key}=#{value}" end.sort.join(' ') end |