1 package DBIx::Class::Serialize;
3 use Storable qw/freeze thaw/;
6 my ($self,$cloning) = @_;
8 my $to_serialize = { %$self };
9 delete $to_serialize->{result_source};
10 return (freeze($to_serialize));
14 my ($self,$cloning,$serialized) = @_;
15 %$self = %{ thaw($serialized) };
16 $self->result_source($self->result_source_instance);
25 DBIx::Class::Serialize - hooks for Storable freeze/thaw (EXPERIMENTAL)
29 # in a table class definition
30 __PACKAGE__->load_components(qw/Serialize/);
32 # meanwhile, in a nearby piece of code
33 my $obj = $schema->resultset('Foo')->find(12);
34 $cache->set($obj->ID, $obj); # if the cache uses Storable, this will work automatically
38 This component adds hooks for Storable so that row objects can be serialized. It assumes that
39 your row object class (C<result_class>) is the same as your table class, which is the normal
40 situation. However, this code is not yet well tested, and so should be considered experimental.
44 David Kamholz <dkamholz@cpan.org>
48 You may distribute this code under the same terms as Perl itself.