module BitGirder::MySql
Public Class Methods
connect( *argv )
click to toggle source
# File lib/bitgirder/mysql.rb, line 22 def self.connect( *argv ) case argv.size when 0 then raise "Need connect args" when 1 case argv[ 0 ] when Hash then connect_from_hash( argv[ 0 ] ) else @@mysql.connect( *argv ) # assume passthrough args end else raise ArgumentError, "Unexpected argv: #{argv}" end end
connect_from_hash( h )
click to toggle source
# File lib/bitgirder/mysql.rb, line 14 def self.connect_from_hash( h ) flattened = h.values_at( :host, :user, :password, :db, :port, :socket ) flattened << ( h[ :flag ] || 0 ) @@mysql.connect( *flattened ) end
flush_privileges( db )
click to toggle source
# File lib/bitgirder/mysql.rb, line 49 def self.flush_privileges( db ) not_nil( db, :db ) db.query( "flush privileges" ) end
open( *argv ) { |mysql| ... }
click to toggle source
# File lib/bitgirder/mysql.rb, line 38 def self.open( *argv ) mysql = connect( *argv ) begin yield( mysql ) ensure mysql.close end end
quote( str )
click to toggle source
# File lib/bitgirder/mysql.rb, line 55 def self.quote( str ) @@mysql.quote( str ) end