Alle mercoled16 maggio 2007, edlich / gmail.com ha scritto:
> 2. Can I modify the getter of any instance var?!
> -> E.g. if an attribute defines attr_accessor, can I change the getter
> at
> runtime to do magic aspect stuff around the real get call?

attr_accessor :var simply defines a method called var which returns the 
instance variable @var. You can redefine it as you would with any other 
method.

class C
 attr_accessor :var
 def initialize value
  @var = value
 end
end

c = C.new 3
puts c.var
=>3

C.module_eval{def var; return 2;end}
c.var => 2

I hope this helps

Stefano