spelling fixes in the documaentation, sholud be gud now ;)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / ColumnsAsHash.pm
index 9a006d6..494dbb9 100644 (file)
@@ -7,11 +7,11 @@ 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
 
-See DBIx::Class::CDBICompat for directions for use.
+See DBIx::Class::CDBICompat for usage directions.
 
 =head1 DESCRIPTION
 
@@ -39,22 +39,21 @@ 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";
         }
 
-        next unless $self->can($col);
         tie $self->{$col}, 'DBIx::Class::CDBICompat::Tied::ColumnValue',
             $self, $col;
     }
@@ -84,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 {
@@ -96,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;