In this example, I have defined two classes - MyValue, and MyValueBool.
MyValueBool is meant to do the same thing as MyValue, except that the
value is restricted to a boolean.
The problem is that the 'around' function only gets called when using
the base class.
This succeeds - around 'value' is called.
$f = MyValue->new ;
$n = $f->value ;
This fails - around 'value' is not called.
$f = MyValueBool->new ;
$n = $f->value ;
Without repeating the 'around' routine, what should I do?
Thanks,
Peter
package MyValue ;
use Mouse ;
has 'value' => ( is => 'rw' ) ;
around 'value' => sub {
print "IN AROUND\n" ;
return 1 ;
} ;
__PACKAGE__->meta->strict_constructor(1);
__PACKAGE__->meta->make_immutable;
no Mouse ;
package MyValueBool ;
use Mouse ;
extends 'MyValue' ;
has '+value' => (
isa => 'Bool',
);
__PACKAGE__->meta->strict_constructor(1);
__PACKAGE__->meta->make_immutable;
no Mouse ;
1;
package main ;
my $f = MyValueBool->new ;
my $n = $f->value ;