Max Muermann wrote:
>>
>> # Observer
>> class Watcher
>>    def initialize m
>>      m.when_name Object do
>>        puts "name set to #{m.name.inspect}"
>>      end
>>
>>      m.when_id Object do
>>        puts "id set to #{m.id.inspect}"
>>      end
>>      # note that each method is treated separately
> 
> Yes, this is probably the most widely useful approach. I have found
> that sometimes, though, you want to be notified if *any* of the state
> in an object changes. For example, checking an model object for
> "dirty" and enabling a save button or similar. In those cases, I think
> a generic solution that does not explicitly require defining a watcher
> method on each attribute may be useful.

That's a good point, though I think I would handle it with a #dirty 
method that gets called from within some of the when_ clauses, since 
there are often attributes whose state is not saved.

> By the way, thanks for bringing this up - I wasn't aware of the
> observable :field notation.

It's not a general ruby notation, just something defined in this one 
library.

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407