Method: WIKK::SQL.connect

Defined in:
lib/wikk_mysql2.rb,
lib/wikk_ruby_mysql.rb

.connect(db_config) {|sql| ... } ⇒ NilClass, WIKK_SQL

Create WIKK::SQL instance and set up the mySQL connection.

Parameters:

  • db_config (Configuration)

    Configuration class, Hash, or any class with appropriate attr_readers.

Yield Parameters:

  • sql (WIKK_SQL)

    if a block is given.

Returns:

  • (NilClass)

    if block is given, and closes the mySQL connection.

  • (WIKK_SQL)

    if no block is given, and caller must call sql.close



18
19
20
21
22
23
24
25
26
27
# File 'lib/wikk_mysql2.rb', line 18

def self.connect(db_config)
  sql = self.new
  sql.connect(db_config)
  if block_given?
    yield sql
    return sql.close
  else
    return sql
  end
end