8 my $schema = DBICTest->init_schema();
13 { module => 'YAML.pm',
14 inflater => sub { YAML::Load (shift) },
15 deflater => sub { die "Expecting a reference" unless (ref $_[0]); YAML::Dump (shift) },
17 { module => 'Storable.pm',
18 inflater => sub { Storable::thaw (shift) },
19 deflater => sub { die "Expecting a reference" unless (ref $_[0]); Storable::nfreeze (shift) },
25 foreach my $serializer (@serializers) {
26 eval { require $serializer->{module} };
28 $selected = $serializer;
33 plan (skip_all => "No suitable serializer found") unless $selected;
36 DBICTest::Schema::Serialized->inflate_column( 'serialized',
37 { inflate => $selected->{inflater},
38 deflate => $selected->{deflater},
41 Class::C3->reinitialize;
60 my $rs = $schema->resultset('Serialized');
63 #======= testing hashref serialization
65 my $object = $rs->create( {
69 ok($object->update( { serialized => $struct_hash } ), 'hashref deflation');
70 ok($inflated = $object->serialized, 'hashref inflation');
71 is_deeply($inflated, $struct_hash, 'inflated hash matches original');
73 $object = $rs->create( {
77 eval { $object->set_inflated_column('serialized', $struct_hash) };
78 ok(!$@, 'set_inflated_column to a hashref');
79 is_deeply($object->serialized, $struct_hash, 'inflated hash matches original');
82 #====== testing arrayref serialization
84 ok($object->update( { serialized => $struct_array } ), 'arrayref deflation');
85 ok($inflated = $object->serialized, 'arrayref inflation');
86 is_deeply($inflated, $struct_array, 'inflated array matches original');