From: Trans Date: 2005-10-21T08:31:59+09:00 Subject: Re: Reflection, observ(er|able) instance vars? Use Module, or better yet your own mixin. And just do the class eval yourself w/o metaid, it's pretty easy module HashAttr def attr_hashing( *arr ) attr_reader *arr arr.each do |var| class_eval %{ def #{var}(val) ; @var ; end } class_eval %{ def #{var}=(val) @var=val @thehash = nil #reset end } end end end Then do class Wombat extend HashAttr attr_hashing :wom, :bat attr_reader :thehash def initialize @wom = "wom" @bat = "bat" @thehash = nil end def hash puts "hash called" @thehash ||= (@wom.to_s + @bat.to_s).hash end def to_s @wom.inspect + @bat.inspect end # compare def ==( other ) hash == other.hash end end HTH, T.