Hi all,

i need some help with finding attributes of an object
lets say i have:

class Obj1
    attr_accessor :val1
end

module Mod1
    attr_accessor :val2
end

module Mod2
    attr_accessor :val3
end

class Obj2 < Obj1
    include Mod1
    include Mod2

    attr_accessor :val4
end

i need a method like  this

obj = Obj2.new
inspect obj                   -> ['val1', 'val2', 'val3', 'val4']


any help really apreciated ! thanks in advance !

-g.


ps: i tried something like this, but i am sure there is a MUCH better
solution.

  def inspect(object)
  attributes = []
  values = []
  object.class.included_modules.each do |m|
   m.instance_methods.grep(%r{=}).each do |a|
    a.chop!
    v = object.send(a)
    if v
     if v.kind_of? String
      values << "'" + v + "'"
     else
      values << v
     end
     attributes << a
    end
   end if Kernel != m
  end
   self.instance_methods.grep(%r{=}).each do |a|
    a.chop!
    v = object.send(a)
    if v
     if v.kind_of? String
      values << "'" + v + "'"
     else
      values << v
     end
     attributes << a
    end
   end
    [attributes, values]
  end