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