Devin Mullins
6/23/2005 1:46:00 AM
I'm not sure I'd ever use it, but if you're looking for ideas, I think a
protocol by which to register observers would be pretty neat.
*reads email about 'observable' library*
I mean, uh, an improvement over the observable library. Something like
this, perchance:
class C
has :a, :observers => true
has :b, :validators => true
end
c = C.new
c.observe(:a) { |old,new|
blah
}
c.observe(:a) { |old,new|
additional_blah
}
c.validate(:b) { |old,new|
blah?
}
If not blah?, then b is not changed.
I'm not sure what it should do, in the observe case, should the block
throw an exception.
Also, if you could think of a good way to allow the object to internally
add observers/validators, even if observers isn't true. Ideally, modify
the protocol to make use of Ruby access control. Maybe give them
individual private methods, such as observe-a and validate-b. Maybe,
instead, just make add_observer and add_validator private methods that
do the same thing.
Or, yeah, I could just direct these suggestions to the author of
'observable'. ;)
Devin