From: David Kamholz Date: Sat, 11 Feb 2006 21:19:31 +0000 (+0000) Subject: - move Serialize.pm to Serialize/Storable.pm X-Git-Tag: v0.06000~61^2~40 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=69ac22eeebd93c172c5669eeddc1decbae70b9b8;p=dbsrgits%2FDBIx-Class.git - move Serialize.pm to Serialize/Storable.pm - add it to Core - add basic test for it --- diff --git a/lib/DBIx/Class/Core.pm b/lib/DBIx/Class/Core.pm index 303d1cc..455e741 100644 --- a/lib/DBIx/Class/Core.pm +++ b/lib/DBIx/Class/Core.pm @@ -7,6 +7,7 @@ no warnings 'qw'; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/ + Serialize::Storable InflateColumn Relationship PK diff --git a/lib/DBIx/Class/Serialize.pm b/lib/DBIx/Class/Serialize/Storable.pm similarity index 77% rename from lib/DBIx/Class/Serialize.pm rename to lib/DBIx/Class/Serialize/Storable.pm index 345b99c..48c4597 100644 --- a/lib/DBIx/Class/Serialize.pm +++ b/lib/DBIx/Class/Serialize/Storable.pm @@ -1,18 +1,17 @@ -package DBIx::Class::Serialize; +package DBIx::Class::Serialize::Storable; use strict; -use Storable qw/freeze thaw/; +use Storable; sub STORABLE_freeze { my ($self,$cloning) = @_; - #return if $cloning; my $to_serialize = { %$self }; delete $to_serialize->{result_source}; - return (freeze($to_serialize)); + return (Storable::freeze($to_serialize)); } sub STORABLE_thaw { my ($self,$cloning,$serialized) = @_; - %$self = %{ thaw($serialized) }; + %$self = %{ Storable::thaw($serialized) }; $self->result_source($self->result_source_instance); } @@ -22,12 +21,12 @@ __END__ =head1 NAME - DBIx::Class::Serialize - hooks for Storable freeze/thaw (EXPERIMENTAL) + DBIx::Class::Serialize::Storable - hooks for Storable freeze/thaw (EXPERIMENTAL) =head1 SYNOPSIS # in a table class definition - __PACKAGE__->load_components(qw/Serialize/); + __PACKAGE__->load_components(qw/Serialize::Storable/); # meanwhile, in a nearby piece of code my $obj = $schema->resultset('Foo')->find(12); diff --git a/t/basicrels/21serialize.t b/t/basicrels/21serialize.t new file mode 100644 index 0000000..60e401d --- /dev/null +++ b/t/basicrels/21serialize.t @@ -0,0 +1,7 @@ +use Test::More; +use lib qw(t/lib); +use DBICTest; +use DBICTest::BasicRels; + +require "t/run/21serialize.tl"; +run_tests(DBICTest->schema); diff --git a/t/helperrels/21serialize.t b/t/helperrels/21serialize.t new file mode 100644 index 0000000..0db9775 --- /dev/null +++ b/t/helperrels/21serialize.t @@ -0,0 +1,7 @@ +use Test::More; +use lib qw(t/lib); +use DBICTest; +use DBICTest::HelperRels; + +require "t/run/21serialize.tl"; +run_tests(DBICTest->schema); diff --git a/t/run/21serialize.tl b/t/run/21serialize.tl new file mode 100644 index 0000000..7c746f2 --- /dev/null +++ b/t/run/21serialize.tl @@ -0,0 +1,14 @@ +use Storable; + +sub run_tests { +my $schema = shift; + +plan tests => 1; + +my $artist = $schema->resultset('Artist')->find(1); +my $copy = eval { Storable::dclone($artist) }; +is_deeply($copy, $artist, 'serialize row object works'); + +} + +1;