Made do_txn respect void context (on the off-chance somebody cares)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Schema.pm
index 7e39162..7df9d5f 100644 (file)
@@ -205,7 +205,9 @@ sub load_classes {
         my $comp_class = "${prefix}::${comp}";
         eval "use $comp_class"; # If it fails, assume the user fixed it
         if ($@) {
-          die $@ unless $@ =~ /Can't locate/;
+         $comp_class =~ s/::/\//g;
+          die $@ unless $@ =~ /Can't locate.+$comp_class\.pm\sin\s\@INC/;
+         warn $@ if $@;
         }
         push(@to_register, [ $comp, $comp_class ]);
       }
@@ -449,10 +451,16 @@ sub txn_do {
   eval {
     # Need to differentiate between scalar/list context to allow for returning
     # a list in scalar context to get the size of the list
+
     if ($wantarray) {
+      # list context
       @return_values = $coderef->(@args);
-    } else {
+    } elsif (defined $wantarray) {
+      # scalar context
       $return_value = $coderef->(@args);
+    } else {
+      # void context
+      $coderef->(@args);
     }
     $self->txn_commit;
   };
@@ -519,11 +527,13 @@ sub populate {
   my ($self, $name, $data) = @_;
   my $rs = $self->resultset($name);
   my @names = @{shift(@$data)};
+  my @created;
   foreach my $item (@$data) {
     my %create;
     @create{@names} = @$item;
-    $rs->create(\%create);
+    push(@created, $rs->create(\%create));
   }
+  return @created;
 }
 
 =head2 throw_exception