1 package DBIx::Class::Serialize::Storable;
7 my ($self,$cloning) = @_;
8 my $to_serialize = { %$self };
9 delete $to_serialize->{result_source};
10 return (Storable::freeze($to_serialize));
14 my ($self,$cloning,$serialized) = @_;
15 %$self = %{ Storable::thaw($serialized) };
16 $self->result_source($self->result_source_instance)
17 if $self->can('result_source_instance');
26 DBIx::Class::Serialize::Storable - hooks for Storable freeze/thaw
30 # in a table class definition
31 __PACKAGE__->load_components(qw/Serialize::Storable/);
33 # meanwhile, in a nearby piece of code
34 my $cd = $schema->resultset('CD')->find(12);
35 # if the cache uses Storable, this will work automatically
36 $cache->set($cd->ID, $cd);
40 This component adds hooks for Storable so that row objects can be
41 serialized. It assumes that your row object class (C<result_class>) is
42 the same as your table class, which is the normal situation.
46 The following hooks are defined for L<Storable> - see the
47 documentation for L<Storable/Hooks> for detailed information on these
50 =head2 STORABLE_freeze
52 The serializing hook, called on the object during serialization. It
53 can be inherited, or defined in the class itself, like any other
58 The deserializing hook called on the object during deserialization.
62 David Kamholz <dkamholz@cpan.org>
66 You may distribute this code under the same terms as Perl itself.