6 use Test::More tests => 9;
11 use_ok('MooseX::Storage');
12 use_ok('MooseX::Storage::Engine');
17 This is just a simple example of defining
18 a custom type handler to take care of custom
19 inflate and deflate needs.
27 has 'baz' => (is => 'rw', isa => 'Str');
28 has 'boo' => (is => 'rw', isa => 'Str');
32 $self->baz . '|' . $self->boo;
36 my ($class, $packed) = @_;
37 my ($baz, $boo) = split /\|/ => $packed;
44 MooseX::Storage::Engine->add_custom_type_handler(
46 expand => sub { Bar->decode(shift) },
47 collapse => sub { (shift)->encode },
61 Bar->new(baz => 'BAZ', boo => 'BOO')
69 isa_ok($foo->bar, 'Bar');
77 '... got correct packed structure');
80 my $foo = Foo->unpack({
86 isa_ok($foo->bar, 'Bar');
88 is($foo->bar->baz, 'BAZ', '... got the right stuff');
89 is($foo->bar->boo, 'BOO', '... got the right stuff');