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