4 use Test::More tests => 9;
9 use_ok('MooseX::Storage');
10 use_ok('MooseX::Storage::Engine');
15 This is just a simple example of defining
16 a custom type handler to take care of custom
17 inflate and deflate needs.
25 has 'baz' => (is => 'rw', isa => 'Str');
26 has 'boo' => (is => 'rw', isa => 'Str');
30 $self->baz . '|' . $self->boo;
34 my ($class, $packed) = @_;
35 my ($baz, $boo) = split /\|/ => $packed;
42 MooseX::Storage::Engine->add_custom_type_handler(
44 expand => sub { Bar->decode(shift) },
45 collapse => sub { (shift)->encode },
59 Bar->new(baz => 'BAZ', boo => 'BOO')
67 isa_ok($foo->bar, 'Bar');
75 '... got correct packed structure');
78 my $foo = Foo->unpack({
84 isa_ok($foo->bar, 'Bar');
86 is($foo->bar->baz, 'BAZ', '... got the right stuff');
87 is($foo->bar->boo, 'BOO', '... got the right stuff');