AUTHORS mass update; mst doesn't have to take credit for -everything- :)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Serialize / Storable.pm
1 package DBIx::Class::Serialize::Storable;
2 use strict;
3 use warnings;
4
5 use Storable();
6 use DBIx::Class::Carp;
7
8 carp 'The Serialize::Storable component is now *DEPRECATED*. It has not '
9     .'been providing any useful functionality for quite a while, and in fact '
10     .'destroys prefetched results in its current implementation. Do not use!';
11
12
13 sub STORABLE_freeze {
14     my ($self, $cloning) = @_;
15     my $to_serialize = { %$self };
16
17     # Dynamic values, easy to recalculate
18     delete $to_serialize->{$_} for qw/related_resultsets _inflated_column/;
19
20     return (Storable::nfreeze($to_serialize));
21 }
22
23 sub STORABLE_thaw {
24     my ($self, $cloning, $serialized) = @_;
25
26     %$self = %{ Storable::thaw($serialized) };
27 }
28
29 1;
30
31 __END__
32
33 =head1 NAME
34
35     DBIx::Class::Serialize::Storable - hooks for Storable nfreeze/thaw
36
37 =head1 DEPRECATION NOTE
38
39 This component is now B<DEPRECATED>. It has not been providing any useful
40 functionality for quite a while, and in fact destroys prefetched results
41 in its current implementation. Do not use!
42
43 =head1 SYNOPSIS
44
45     # in a table class definition
46     __PACKAGE__->load_components(qw/Serialize::Storable/);
47
48     # meanwhile, in a nearby piece of code
49     my $cd = $schema->resultset('CD')->find(12);
50     # if the cache uses Storable, this will work automatically
51     $cache->set($cd->ID, $cd);
52
53 =head1 DESCRIPTION
54
55 This component adds hooks for Storable so that row objects can be
56 serialized. It assumes that your row object class (C<result_class>) is
57 the same as your table class, which is the normal situation.
58
59 =head1 HOOKS
60
61 The following hooks are defined for L<Storable> - see the
62 documentation for L<Storable/Hooks> for detailed information on these
63 hooks.
64
65 =head2 STORABLE_freeze
66
67 The serializing hook, called on the object during serialization. It
68 can be inherited, or defined in the class itself, like any other
69 method.
70
71 =head2 STORABLE_thaw
72
73 The deserializing hook called on the object during deserialization.
74
75 =head1 AUTHOR AND CONTRIBUTORS
76
77 See L<AUTHOR|DBIx::Class/AUTHOR> and L<CONTRIBUTORS|DBIx::Class/CONTRIBUTORS> in DBIx::Class
78
79 =head1 LICENSE
80
81 You may distribute this code under the same terms as Perl itself.
82
83 =cut