Class: AsyncRecord::Connection::MySQL
- Includes:
- Fastr::Log
- Defined in:
- lib/async_record/connections/mysql.rb
Instance Attribute Summary collapse
-
#connections ⇒ Object
Returns the value of attribute connections.
-
#database ⇒ Object
Returns the value of attribute database.
-
#host ⇒ Object
Returns the value of attribute host.
-
#mysql ⇒ Object
Returns the value of attribute mysql.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(*args) ⇒ MySQL
constructor
Initializes a MySQL connection.
- #query(queryStr, &blk) ⇒ Object
Constructor Details
#initialize(*args) ⇒ MySQL
Initializes a MySQL connection
18 19 20 21 22 23 24 25 26 |
# File 'lib/async_record/connections/mysql.rb', line 18 def initialize(*args) args.each do |arg| if arg.kind_of? Hash arg.each do |k,v| self.send("#{k}=", v) end end end end |
Instance Attribute Details
#connections ⇒ Object
Returns the value of attribute connections.
13 14 15 |
# File 'lib/async_record/connections/mysql.rb', line 13 def connections @connections end |
#database ⇒ Object
Returns the value of attribute database.
12 13 14 |
# File 'lib/async_record/connections/mysql.rb', line 12 def database @database end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/async_record/connections/mysql.rb', line 8 def host @host end |
#mysql ⇒ Object
Returns the value of attribute mysql.
15 16 17 |
# File 'lib/async_record/connections/mysql.rb', line 15 def mysql @mysql end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/async_record/connections/mysql.rb', line 11 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
9 10 11 |
# File 'lib/async_record/connections/mysql.rb', line 9 def port @port end |
#user ⇒ Object
Returns the value of attribute user.
10 11 12 |
# File 'lib/async_record/connections/mysql.rb', line 10 def user @user end |
Instance Method Details
#connect ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/async_record/connections/mysql.rb', line 28 def connect settings = {:logging => false, :connections => 4} settings[:host] = self.host if not self.host.nil? settings[:port] = self.port if not self.port.nil? settings[:user] = self.user if not self.user.nil? settings[:password] = self.password if not self.password.nil? settings[:database] = self.database if not self.database.nil? settings[:connections] = self.connections if not self.connections.nil? EventedMysql.settings.update(settings) end |
#query(queryStr, &blk) ⇒ Object
41 42 43 |
# File 'lib/async_record/connections/mysql.rb', line 41 def query(queryStr, &blk) EventedMysql.select(queryStr, &blk) end |