6 use Test::More tests => 9;
10 use_ok('MooseX::Storage');
11 use_ok('MooseX::Storage::Engine');
16 This is just a simple example of defining
17 a custom type handler to take care of custom
18 inflate and deflate needs.
26 has 'baz' => (is => 'rw', isa => 'Str');
27 has 'boo' => (is => 'rw', isa => 'Str');
31 $self->baz . '|' . $self->boo;
35 my ($class, $packed) = @_;
36 my ($baz, $boo) = split /\|/ => $packed;
43 MooseX::Storage::Engine->add_custom_type_handler(
45 expand => sub { Bar->decode(shift) },
46 collapse => sub { (shift)->encode },
60 Bar->new(baz => 'BAZ', boo => 'BOO')
68 isa_ok($foo->bar, 'Bar');
76 '... got correct packed structure');
79 my $foo = Foo->unpack({
85 isa_ok($foo->bar, 'Bar');
87 is($foo->bar->baz, 'BAZ', '... got the right stuff');
88 is($foo->bar->boo, 'BOO', '... got the right stuff');