X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FCDBICompat%2FColumnsAsHash.pm;h=291db64a2e82bdac85ee7ae61dbc3a94f345710d;hb=c58270743fa0bebf1410d02136b3f82ec8838feb;hp=dd02a63fed8d57a4c2fb8f1a1c5e71befdaf9800;hpb=d656262b3d0469fc3216a67d3b9fb070110632bd;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm b/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm index dd02a63..291db64 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm @@ -7,7 +7,7 @@ use warnings; =head1 NAME -DBIx::Class::CDBICompat::ColumnsAsHash +DBIx::Class::CDBICompat::ColumnsAsHash - Emulates the behavior of Class::DBI where the object can be accessed as a hash of columns. =head1 SYNOPSIS @@ -39,16 +39,16 @@ sub inflate_result { my $class = shift; my $new = $class->next::method(@_); - + $new->_make_columns_as_hash; - + return $new; } sub _make_columns_as_hash { my $self = shift; - + for my $col ($self->columns) { if( exists $self->{$col} ) { warn "Skipping mapping $col to a hash key because it exists"; @@ -83,7 +83,9 @@ sub FETCH { carp "Column '$col' of '$class/$id' was fetched as a hash" if $ENV{DBIC_CDBICOMPAT_HASH_WARN}; - return $obj->get_column($col); + return $obj->column_info($col)->{_inflate_info} + ? $obj->get_inflated_column($col) + : $obj->get_column($col); } sub STORE { @@ -95,7 +97,9 @@ sub STORE { carp "Column '$col' of '$class/$id' was stored as a hash" if $ENV{DBIC_CDBICOMPAT_HASH_WARN}; - $obj->set_column($col => shift); + return $obj->column_info($col)->{_inflate_info} + ? $obj->set_inflated_column($col => shift) + : $obj->set_column($col => shift); } 1;