has priv_attr => (
is => 'rw',
isa => 'Str',
reader => '_priv_attr',
writer => '_priv_attr'
);
####
sub do_stuff {
my $self = shift;
$self->_priv_attr( 1 );
$self->_priv_attr;
}
####
Attribute (priv_attr) does not pass the type constraint because: Validation failed for 'Str' with value undef at ./test.pl line 22
Foo::do_stuff('Foo=HASH(0x8d02c18)') called at ./test.pl line 28
####
#!/usr/bin/env perl
use warnings;
use strict;
{
package Foo;
use Moose;
has priv_attr => (
is => 'rw',
isa => 'Str',
reader => '_priv_attr',
writer => '_priv_attr'
);
sub do_stuff {
my $self = shift;
$self->_priv_attr( 1 );
$self->_priv_attr;
}
1;
}
Foo->new->do_stuff;