Commit | Line | Data |
ed28f830 |
1 | package DBIx::Class::Serialize; |
2 | use strict; |
3 | use Storable qw/freeze thaw/; |
4 | |
5 | sub STORABLE_freeze { |
6 | my ($self,$cloning) = @_; |
7 | return if $cloning; |
8 | my $to_serialize = { %$self }; |
9 | delete $to_serialize->{result_source}; |
10 | return (freeze($to_serialize)); |
11 | } |
12 | |
13 | sub STORABLE_thaw { |
14 | my ($self,$cloning,$serialized) = @_; |
15 | %$self = %{ thaw($serialized) }; |
16 | no strict 'refs'; |
17 | my $class = ${(ref $self) . '::ISA'}[0]; |
18 | my $schema = DB->schema; |
19 | $self->result_source($schema->source($class)); |
20 | } |
21 | |
22 | 1; |