| ☞ | Program
Repair Shop ![]() |
39 |
Suppose you have:
my $g = Guard->new("Fred");
my $an = Alarm::Noisy->new(...); # derived class of Alarm
Alarm->add_observer($g); # $g observes all "Alarm" objects
$an->notify_observers("I like pie!");
This notifies $g
In general, if $g is watching some class, it also watches all its subclasses
The logic for this is in _obs_get_parent_observers
(What is "_obs" for?)
When we ask for the observers of some object, we get not just the direct observers
Also the observers of its class
And any base classes of its class
| ☞ | ![]() |
☞ |