From: ts Date: 2002-09-27T21:20:03+09:00 Subject: Re: object attributes list >>>>> "K" == Kent Dahl writes: K> Not sure this will work too well when we get truely private instance K> variables (i.e. protected from subclasses... Will they also be protected K> from superclasses?) Well, actually my stupid implementation do this pigeon% cat b.rb #!./ruby class Customer def initialize @_Customerid = 123 @_city = 'abc' @_secret = 'hush hush' end end c = Customer.new class Object def class_local_variables_to_hash result = {} self.class_local_variables(type).each do |var| result[var] = eval var end result end end hash = c.class_local_variables_to_hash hash.each_key {|key| puts "\"#{key}\" => \"#{hash[key]}\""} pigeon% pigeon% b.rb "@_city" => "" "@_secret" => "" "@_Customerid" => "" pigeon% #eval is evaluated with current_class == rb_cObject Guy Decoux