From: Alex LeDonne Date: 2007-11-28T01:20:48+09:00 Subject: Re: Object Oriented Help On Nov 26, 2007 8:03 PM, Matt Berney wrote: > We have been using Ruby/Watir for quite some time now. It is a useful > combination. The object-oriented nature of Ruby with Modules, classes > and mixins works really well. > > Now my dilema... > > Currently we have one database object that implements methods for > customers, payment devices, and sva (Stored Value Accounts). > > d = Database.new > > d.getCustomerIDByOrder > d.customerBlacklisted? > d.customerValidated? > > d.getPaymentDeviceByOrder > d.paymentDeviceBlacklisted? > d.paymentDeviceValidated? > > d.getSvaIDByOrder > d.svaBlacklisted? > d.svaValidated? > > What is a good way to create an object that publishes common interfaces > that calls the device specific methods as appropriate? > > Something like ... > getIDByOrder(), blacklisted?(), validated?() > > But, how to create the hierarchy to call the appropriate low level > primitives? > > Perhaps have a Customer object, PaymentDevice object, and Sva object > that each publishes their own interfaces. But, then what next? > > TIA This is precisely what an ORM (Object Relational Mapper) does, mostly automagically. Some of the ORMs I've heard of in Ruby are ActiveRecord (used in Rails), Og (used in Nitro), Kansas (used in Iowa), Sequel, and DataMapper. I'm sure there are others. A google search for Ruby ORM and any of those project names will be very fruitful for you. Best of luck! -A