Function not called in base class

[email protected] (Peter Gordon)
Newsgroups perl.moose
Message-ID <1301389779.6156.12.camel@qed>
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 ;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.