[Bast-commits] r4824 - in DBIx-Class/0.08/trunk: lib/DBIx/Class/ResultClass t

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Fri Sep 19 13:39:23 BST 2008


Author: matthewt
Date: 2008-09-19 13:39:23 +0100 (Fri, 19 Sep 2008)
New Revision: 4824

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultClass/HashRefInflator.pm
   DBIx-Class/0.08/trunk/t/68inflate_resultclass_hashrefinflator.t
Log:
removed retarded global; if you want this feature, make it a bloody constructor argument, what I'm deleting is -not- DBIC core quality code

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultClass/HashRefInflator.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultClass/HashRefInflator.pm	2008-09-19 11:32:11 UTC (rev 4823)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultClass/HashRefInflator.pm	2008-09-19 12:39:23 UTC (rev 4824)
@@ -3,9 +3,6 @@
 use strict;
 use warnings;
 
-our %inflator_cache;
-our $inflate_data;
-
 =head1 NAME
 
 DBIx::Class::ResultClass::HashRefInflator
@@ -64,7 +61,6 @@
     my ($self, $source, $me, $prefetch) = @_;
 
     my $hashref = mk_hash($me, $prefetch);
-    inflate_hash ($source->schema, $source->result_class, $hashref) if $inflate_data;
     return $hashref;
 }
 
@@ -108,45 +104,6 @@
     }
 }
 
-=head2 inflate_hash
-
-This walks through a hashref produced by L<mk_hash> and inflates any data 
-for which there is a registered inflator in the C<column_info>
-
-=cut
-
-sub inflate_hash {
-    my ($schema, $rc, $data) = @_;
-
-    foreach my $column (keys %{$data}) {
-
-        if (ref $data->{$column} eq 'HASH') {
-            inflate_hash ($schema, $schema->source ($rc)->related_class ($column), $data->{$column});
-        } 
-        elsif (ref $data->{$column} eq 'ARRAY') {
-            foreach my $rel (@{$data->{$column}}) {
-                inflate_hash ($schema, $schema->source ($rc)->related_class ($column), $rel);
-            }
-        }
-        else {
-            # "null is null is null"
-            next if not defined $data->{$column};
-
-            # cache the inflator coderef
-            unless (exists $inflator_cache{$rc}{$column}) {
-                $inflator_cache{$rc}{$column} = exists $schema->source ($rc)->_relationships->{$column}
-                    ? undef     # currently no way to inflate a column sharing a name with a rel 
-                    : $rc->column_info($column)->{_inflate_info}{inflate}
-                ;
-            }
-
-            if ($inflator_cache{$rc}{$column}) {
-                $data->{$column} = $inflator_cache{$rc}{$column}->($data->{$column});
-            }
-        }
-    }
-}
-
 =head1 CAVEAT
 
 This will not work for relationships that have been prefetched. Consider the

Modified: DBIx-Class/0.08/trunk/t/68inflate_resultclass_hashrefinflator.t
===================================================================
--- DBIx-Class/0.08/trunk/t/68inflate_resultclass_hashrefinflator.t	2008-09-19 11:32:11 UTC (rev 4823)
+++ DBIx-Class/0.08/trunk/t/68inflate_resultclass_hashrefinflator.t	2008-09-19 12:39:23 UTC (rev 4824)
@@ -131,9 +131,3 @@
 my $cd = $cd_rs->first;
 ok ( (not blessed $cd->{year}), "Plain string returned for year");
 is ( $cd->{year}, '1997', "We are looking at the right year");
-
-# try it again with inflation requested
-local $DBIx::Class::ResultClass::HashRefInflator::inflate_data = 1;
-my $cd2 = $cd_rs->first;
-isa_ok ($cd2->{year}, 'DateTime', "Inflated object");
-is ($cd2->{year}, DateTime->new ( year => 1997 ), "Correct year was inflated");




More information about the Bast-commits mailing list