☞ | ![]() ![]() |
59 |
Hey, I almost forgot the most important method of all!
83 sub notify_observers { 84 my ( $item, $action, @params ) = @_; 85 $action ||= ''; 88 my @observers = $item->get_observers; 89 foreach my $o ( @observers ) { 91 eval { 92 if ( ref $o eq 'CODE' ) { 93 $o->( $item, $action, @params ); 95 else { 96 $o->update( $item, $action, @params ); 99 if ( $@ ) { 100 $item->observer_error( 101 "Failed to send observation from '$item' to '$o': $@" );
I didn't trim this very much
I got rid of the special handling of $action
I collapsed 88-89 to a single line:
for my $o ($self->get_observers) {
☞ | ![]() |
☞ |