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