X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSourceHandle.pm;h=474c9a4a4c6cb883036cd95f6a58c1d0f334d565;hb=1b6fe47d369e84831a8a881813a53cca68694e72;hp=4a402e9d0e4962d2c104caf1814e6f68459b3537;hpb=d4daee7b54e38e4b3d3d0a77759bddc1a4ede6e5;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSourceHandle.pm b/lib/DBIx/Class/ResultSourceHandle.pm index 4a402e9..474c9a4 100644 --- a/lib/DBIx/Class/ResultSourceHandle.pm +++ b/lib/DBIx/Class/ResultSourceHandle.pm @@ -39,10 +39,6 @@ will have a C<$schema> object through their source handle Large output when using Data::Dump(er) since this class can be set to stringify to almost nothing -=item * - -Closer to being able to do a Serialize::Storable that doesn't require class-based connections - =back =head1 METHODS @@ -78,25 +74,26 @@ sub STORABLE_freeze { my $to_serialize = { %$self }; - my $class = $self->schema->class($self->source_moniker); - $to_serialize->{schema} = $class; - return (Storable::freeze($to_serialize)); + delete $to_serialize->{schema}; + $to_serialize->{_frozen_from_class} = $self->schema->class($self->source_moniker); + + return (Storable::nfreeze($to_serialize)); } =head2 STORABLE_thaw Thaws frozen handle. Resets the internal schema reference to the package -variable C<$thaw_schema>. The recomened way of setting this is to use +variable C<$thaw_schema>. The recommended way of setting this is to use C<< $schema->thaw($ice) >> which handles this for you. =cut sub STORABLE_thaw { - my ($self, $cloning,$ice) = @_; + my ($self, $cloning, $ice) = @_; %$self = %{ Storable::thaw($ice) }; - my $class = delete $self->{schema}; + my $class = delete $self->{_frozen_from_class}; if( $thaw_schema ) { $self->{schema} = $thaw_schema; } @@ -105,7 +102,8 @@ sub STORABLE_thaw { $self->{schema} = $rs->schema if $rs; } - carp "Unable to restore schema" unless $self->{schema}; + carp "Unable to restore schema. Look at 'freeze' and 'thaw' methods in DBIx::Class::Schema." + unless $self->{schema}; } =head1 AUTHOR