From: ts Date: 2000-04-04T13:17:22+02:00 Subject: [ruby-talk:02358] Re: setter() for local variables >>>>> "Y" == Yukihiro Matsumoto writes: Y> module DBD Y> class Marshal Y> def initialize(db) Y> @db = db Y> @tbl = {} Y> end Y> def []=(k,v) Y> @tbl[k] = v Y> end Y> def [] Y> @tbl[k] Y> end Y> def close Y> for k,v in @tbl Y> @db[::Mashal::dump(k)] = ::Mashal::dump(v) Y> end Y> @db.close Y> end Y> end I just need to write this, no ? class Toto def initialize(db, key, value) @db, @key, @value = db, key, value @value end def method_missing(id, *args) @value = @db[@key] result = @value.send(id, *args) @db[@key] = @value result end end and with : db = BDB::Btree.open("aa") db[1] = [1, 2] db[1].push(3) db[1] will return a new object Toto. Only the current object is duplicated (i.e. in memory and in the db file) and not the whole db. In this case, do I need to destroy all methods in the class Toto, to have only method_missing ? Do this work for all objects or I'm missing something ? Guy Decoux