require 'fox' require 'mysql' # # MyFXApp - sub-class of Fox::FXApp with MySQL database handle member. # class MyFXApp << Fox::FXApp attr_accessor :db def initialize(db_info, app_name = nil, vendor_name = nil) # connect to database @db = Mysql::connect(db_info['host'], db_info['user'], db_info['pass']) @db.select_db(db_info['db_name']) # initialize the rest of the FXApp object super(app_name, vendor_name) end end # # Example: create a MyFXApp object. # if __FILE__ == $0 # create a hash of database information db_info = { 'host' => 'localhost', 'user' => 'username', 'pass' => 'password', 'db_name' => 'database_name', } # create a new MyFXApp object app = MyFXApp.new(db_info, 'MyFXApp Test', 'Balony Enterprises, Inc.') # ... do other type stuff here end