ScoreBoard.pm
--------------------
package ScoreBoard;
use Moose;
use MooseX::Privacy;
has 'started' => (
traits => [qw/Bool Protected/],
is => 'ro',
isa => 'Bool',
predicate => 'hasGameStarted',
handles => {
startGame => 'set',
},
);
1;
ScoreBoard-test2.pl
--------------------------
#!/opt/local/bin/perl -w
use strict;
use ScoreBoard;
my $sb = ScoreBoard->new;
print "Game has not started yet\n" if !$sb->hasGameStarted;
####
$ ./ScoreBoard-test2.pl
Attribute started is protected at /opt/local/lib/perl5/site_perl/5.12.3/MooseX/Privacy/Meta/Attribute/Protected.pm line 13.
[snip ...]
####
has 'started' => (
traits => [qw/Bool Protected/],
is => 'ro',
isa => 'Bool',
#predicate => 'hasGameStarted',
handles => {
startGame => 'set',
},
);
sub hasGameStarted {
my $self = shift;
return defined $self->started;
}
####
$ ./ScoreBoard-test2.pl
Game has not started yet