From: Wilson Bilkovich Date: 2006-11-16T13:51:53+09:00 Subject: Catching attr_accessor with set_trace_func Code using attr_accessor: class User attr_accessor :something def initialize @something = 0 end end @user = User.new set_trace_func(lambda {|*trace| STDERR.puts trace.inspect}) @user.something ######### prints this to STDERR: ["line", "trace_func.rb", 11, nil, #, false] ######### Functionally equivalent code with a hand-written method, instead of attr_accessor: class User def something @something end def initialize @something = 0 end end @user = User.new set_trace_func(lambda {|*trace| STDERR.puts trace.inspect}) @user.something ######### prints this to STDERR: ["line", "trace_func.rb", 13, nil, #, false] ["call", "trace_func.rb", 2, :something, #, User] ["line", "trace_func.rb", 3, :something, #, User] ["return", "trace_func.rb", 4, :something, #, User] ######### How can I capture the fact that the 'something' accessor was called in the first example?