I have put together a little test case to demonstrate my problem:
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);
I would expect this to print the object, but not the 'lol' attribute in the P2 package - however, I can still see this in the result of $stored->pack
$VAR1 = {
'__CLASS__' => 'P1',
'blah' => bless( {
'magic' => 'This ok!',
'lol' => sub { "DUMMY" }
}, 'P3' )
};
Am I using MooseX::Storage wrong, or does this look like buggy behaviour?
Yup that looks like a bug. Can you turn this into a test that uses Test::More and submit it to the RT queue and someone (probably me) will fix that.
Note that if you Dump $obj->store you see that the trait is properly applied to the direct attribute but it seems that it's getting lost during the inheritance process.
You can report bugs against MooseX::Storage in RT
You can make 'blah' an isa of P3....
has 'blah' => (
is => 'rw',
isa => 'P3',
);
and now Dumper( $stored->pack ) shows this....
$VAR1 = {
'__CLASS__' => 'P1',
'blah' => {
'__CLASS__' => 'P3',
'magic' => 'This ok!'
}
};
which looks like the correct serialisation for this Moose object?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With