Basset

 view release on metacpan or  search on metacpan

lib/Basset/Object.pm  view on Meta::CPAN


=item notify

Used for non-fatal messages, usually an error message that shouldn't cause things to abort. Expects at least one argument,
the notification being posted. Additional arguments will be passed through to any handlers.

 sub lockThing {
 	my $self = shift;
 	my $thing = shift;

 	if ($thing->locked) {
 		$self->notify("info", "Cannot lock - thing is already locked");
 	} else {
 		$thing->lock();
 	};

 	return 1;
 }

In this example, we have a method called "lockThing" that locks a thing (whatever that means). But it only locks the thing
if it is not already locked. If it is locked, it sends an informational message that the thing is already locked. But that's not
fatal - we still end up with a locked thing, so we're happy no matter what. No need to kick back an error.

notify is a wrapper around the notification center.

 $obj->notify('foo') == Basset::NotificationCenter->postNotification('object' => $obj, 'notification' => 'foo');

=cut

=pod

=begin btest(notify)



( run in 0.454 second using v1.01-cache-2.11-cpan-49f99fa48dc )