Class-Observable
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Class/Observable.pm view on Meta::CPAN
if ( $@ ) {
My::Exception->throw( "Error saving: $@" );
}
$self->notify_observers( 'edit', old_values => \%old_values );
}
# Define an observer
package My::Observer;
sub update {
my ( $class, $object, $action ) = @_;
unless ( $action ) {
warn "Cannot operation on [", $object->id, "] without action";
return;
}
$class->_on_save( $object ) if ( $action eq 'save' );
$class->_on_update( $object ) if ( $action eq 'update' );
}
# Register the observer class with all instances of the observable
t/lib/DeeJay.pm view on Meta::CPAN
#print "Let's get this party started!\n";
$self->{current_song} = 0;
$self->{playlist}[0]->play;
}
sub end_party {
my ( $self ) = @_;
#print "Party's over, time to go home\n";
}
sub update {
my ( $self, $song, $action ) = @_;
#print "Caught update [$action] from [$song->{band}]\n";
$self->{update}++;
return unless ( $action eq 'stop_play' );
$self->{update_stop}++;
$self->{current_song}++;
if ( $self->{current_song} == $self->{num_songs} ) {
return $self->end_party;
}
$self->{playlist}[ $self->{current_song} ]->play;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.531 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )