我整理了一个小测试用例来证明我的问题:
package P1;
use Moose;
use MooseX::Storage;
with Storage;
has 'blah' => (
is => 'rw',
);
package P2;
use Moose;
use MooseX::Storage;
with Storage;
has 'lol' => (
is => 'rw',
traits => ['DoNotSerialize']
);
package P3;
use Moose;
extends 'P2';
has 'magic' => (
is => 'rw',
);
package Test;
my $obj = P3->new(
magic => 'This ok!',
lol => sub { 'weee' }
);
my $stored = P1->new(blah => $obj);
use Data::Dumper; print Dumper ($stored->pack);
我希望这会打印对象,而不是 P2 包中的“lol”属性 - 但是,我仍然可以在结果中看到这一点$stored->pack
$VAR1 = {
'__CLASS__' => 'P1',
'blah' => bless( {
'magic' => 'This ok!',
'lol' => sub { "DUMMY" }
}, 'P3' )
};
我是否使用了 MooseX::Storage 错误,或者这看起来像错误的行为?