Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Serialize / Storable.pm
CommitLineData
69ac22ee 1package DBIx::Class::Serialize::Storable;
ed28f830 2use strict;
bf5ecff9 3use warnings;
ed28f830 4
70c28808 5use Storable();
6use DBIx::Class::Carp;
64c50e81 7use namespace::clean;
1b6fe47d 8
9carp 'The Serialize::Storable component is now *DEPRECATED*. It has not '
10 .'been providing any useful functionality for quite a while, and in fact '
11 .'destroys prefetched results in its current implementation. Do not use!';
12
13
ed28f830 14sub STORABLE_freeze {
e60dc79f 15 my ($self, $cloning) = @_;
ed28f830 16 my $to_serialize = { %$self };
e60dc79f 17
7cfda9a6 18 # Dynamic values, easy to recalculate
19 delete $to_serialize->{$_} for qw/related_resultsets _inflated_column/;
e60dc79f 20
26148d36 21 return (Storable::nfreeze($to_serialize));
ed28f830 22}
23
24sub STORABLE_thaw {
7244b45f 25 my ($self, $cloning, $serialized) = @_;
e60dc79f 26
7244b45f 27 %$self = %{ Storable::thaw($serialized) };
ed28f830 28}
29
19345968 301;
31
32__END__
33
75d07914 34=head1 NAME
19345968 35
26148d36 36 DBIx::Class::Serialize::Storable - hooks for Storable nfreeze/thaw
19345968 37
1b6fe47d 38=head1 DEPRECATION NOTE
39
40This component is now B<DEPRECATED>. It has not been providing any useful
41functionality for quite a while, and in fact destroys prefetched results
42in its current implementation. Do not use!
43
19345968 44=head1 SYNOPSIS
45
46 # in a table class definition
69ac22ee 47 __PACKAGE__->load_components(qw/Serialize::Storable/);
9b83fccd 48
19345968 49 # meanwhile, in a nearby piece of code
24d67825 50 my $cd = $schema->resultset('CD')->find(12);
2053ab2a 51 # if the cache uses Storable, this will work automatically
52 $cache->set($cd->ID, $cd);
19345968 53
54=head1 DESCRIPTION
55
fb13a49f 56This component adds hooks for Storable so that result objects can be
57serialized. It assumes that your result object class (C<result_class>) is
2053ab2a 58the same as your table class, which is the normal situation.
19345968 59
9b83fccd 60=head1 HOOKS
61
62The following hooks are defined for L<Storable> - see the
63documentation for L<Storable/Hooks> for detailed information on these
64hooks.
65
66=head2 STORABLE_freeze
67
68The serializing hook, called on the object during serialization. It
69can be inherited, or defined in the class itself, like any other
70method.
71
72=head2 STORABLE_thaw
73
74The deserializing hook called on the object during deserialization.
75
a2bd3796 76=head1 FURTHER QUESTIONS?
19345968 77
a2bd3796 78Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
19345968 79
a2bd3796 80=head1 COPYRIGHT AND LICENSE
19345968 81
a2bd3796 82This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
83by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
84redistribute it and/or modify it under the same terms as the
85L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.