From: Robert Dober Date: 2009-02-09T05:58:48+09:00 Subject: Re: best way to protect class instance variables On Sun, Feb 8, 2009 at 9:48 PM, David Masover wrote: What about fine graining the control to the closure? Not tested: class MyBlah blah = [ 0, 1 ] extend( Module::new do define_method :[] do |idx| blah[ idx ] end define_method :blah do blah.dup.freeze end define_method :[]= do |idx, value| do_all_my_checks blah[ idx ] = some_fancy_function( value ) end end ) end HTH Robert -- It is change, continuing change, inevitable change, that is the dominant factor in society today. No sensible decision can be made any longer without taking into account not only the world as it is, but the world as it will be ... ~ Isaac Asimov