Fixed typos in HashRefInflator example
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Manual / Cookbook.pod
index f2934cb..ab58aaa 100644 (file)
@@ -1114,7 +1114,7 @@ C<inflate_result>:
      my ($me, $rest) = @_;
 
      return { %$me, 
-        map { ($_ => mk_hash(@{$rest->{$_}})) } keys %$rest } 
+        map { ($_ => mk_hash(@{$rest->{$_}})) } keys %$rest
      };
   }
 
@@ -1127,7 +1127,7 @@ C<inflate_result>:
   $rs->result_class('My::HashRefInflator');
 
   my $datahashref = $rs->next;
-  foreach my $col (keys $datahashref) {
+  foreach my $col (keys %$datahashref) {
      if(!ref($datahashref->{$col}) {
         # It's a plain value
      }
@@ -1136,5 +1136,14 @@ C<inflate_result>:
      }
   }
 
-=cut
+=head2 Want to know if find_or_create found or created a row?
+
+Just use C<find_or_new> instead, then check C<in_storage>:
 
+  my $obj = $rs->find_or_new({ blah => 'blarg' });
+  unless ($obj->in_storage) {
+    $obj->insert;
+    # do whatever else you wanted if it was a new row
+  }
+
+=cut