From: Eugene Scripnik Date: 2002-08-23T17:56:13+09:00 Subject: converting rows into structs I have a methods that converts all DB rows into structs using Struct class. First version was: # res - result objects from DB connector def create_structs( res ) row_class = Struct.new( 'SQLRow', *res.names ) data = [] res.each do |row| data << row_class.new( row ) end data end res1 = conn.exec( <<-SQL ) SELECT name, surname FROM user SQL data1 = create_structs( res1 ) # here data1[0] has methods 'name' and 'surname' res2 = conn.exec( <<-SQL ) SELECT age FROM user SQL data2 = create_structs( res2 ) # here both data1 & data2 have method 'age' only # it is due to redefinition of Struct::SQLRow methods I would like to rewrite method create_structs to avoid this problem. -- Best regards, Eugene [team Enticla] mailto:Eugene.Scripnik@itgrp.net