- add docs to Serialize and ResultSetManager
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Serialize.pm
CommitLineData
ed28f830 1package DBIx::Class::Serialize;
2use strict;
3use Storable qw/freeze thaw/;
4
5sub STORABLE_freeze {
6 my ($self,$cloning) = @_;
7 return if $cloning;
8 my $to_serialize = { %$self };
9 delete $to_serialize->{result_source};
10 return (freeze($to_serialize));
11}
12
13sub STORABLE_thaw {
14 my ($self,$cloning,$serialized) = @_;
15 %$self = %{ thaw($serialized) };
49354ee3 16 $self->result_source($self->result_source_instance);
ed28f830 17}
18
19345968 191;
20
21__END__
22
23=head1 NAME
24
25 DBIx::Class::Serialize - hooks for Storable freeze/thaw (EXPERIMENTAL)
26
27=head1 SYNOPSIS
28
29 # in a table class definition
30 __PACKAGE__->load_components(qw/Serialize/);
31
32 # meanwhile, in a nearby piece of code
33 my $obj = $schema->resultset('Foo')->find(12);
34 $cache->set($obj->ID, $obj); # if the cache uses Storable, this will work automatically
35
36=head1 DESCRIPTION
37
38This component adds hooks for Storable so that row objects can be serialized. It assumes that
39your row object class (C<result_class>) is the same as your table class, which is the normal
40situation. However, this code is not yet well tested, and so should be considered experimental.
41
42=head1 AUTHORS
43
44David Kamholz <dkamholz@cpan.org>
45
46=head1 LICENSE
47
48You may distribute this code under the same terms as Perl itself.
49
50=cut