doc fixes
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Schema.pm
index cc6c949..292aef8 100644 (file)
@@ -4,7 +4,6 @@ use strict;
 use warnings;
 
 use Carp::Clan qw/^DBIx::Class/;
-use UNIVERSAL::require;
 
 use base qw/DBIx::Class/;
 
@@ -30,6 +29,7 @@ DBIx::Class::Schema - composable schemas
   __PACKAGE__->load_components(qw/PK::Auto::Pg Core/); # for example
   __PACKAGE__->table('foo');
 
+  # Elsewhere in your code:
   my $schema1 = My::Schema->connect(
     $dsn,
     $user,
@@ -230,7 +230,9 @@ you expect.
 sub compose_connection {
   my ($self, $target, @info) = @_;
   my $base = 'DBIx::Class::ResultSetProxy';
-  $base->require;
+  eval "require ${base};";
+  $self->throw_exception("No arguments to load_classes and couldn't load".
+      " ${base} ($@)") if $@;
 
   if ($self eq $target) {
     # Pathological case, largely caused by the docs on early C::M::DBIC::Plain
@@ -246,6 +248,11 @@ sub compose_connection {
   }
 
   my $schema = $self->compose_namespace($target, $base);
+  {
+    no strict 'refs';
+    *{"${target}::schema"} = sub { $schema };
+  }
+
   $schema->connection(@info);
   foreach my $moniker ($schema->sources) {
     my $source = $schema->source($moniker);
@@ -274,8 +281,6 @@ sub compose_namespace {
   }
   {
     no strict 'refs';
-    *{"${target}::schema"} =
-      sub { $schema };
     foreach my $meth (qw/class source resultset/) {
       *{"${target}::${meth}"} =
         sub { shift->schema->$meth(@_) };
@@ -311,7 +316,9 @@ sub connection {
   my $storage_class = $self->storage_type;
   $storage_class = 'DBIx::Class::Storage'.$storage_class
     if $storage_class =~ m/^::/;
-  $storage_class->require;
+  eval "require ${storage_class};";
+  $self->throw_exception("No arguments to load_classes and couldn't load".
+      " ${storage_class} ($@)") if $@;
   my $storage = $storage_class->new;
   $storage->connect_info(\@info);
   $self->storage($storage);
@@ -324,7 +331,31 @@ Conveneience method, equivalent to $schema->clone->connection(@info)
 
 =cut
 
-sub connect { shift->clone->connection(@_) };
+sub connect { shift->clone->connection(@_) }
+
+=head2 txn_begin
+
+Begins a transaction (does nothing if AutoCommit is off).
+
+=cut
+
+sub txn_begin { shift->storage->txn_begin }
+
+=head2 txn_commit
+
+Commits the current transaction.
+
+=cut
+
+sub txn_commit { shift->storage->txn_commit }
+
+=head2 txn_rollback
+
+Rolls back the current transaction.
+
+=cut
+
+sub txn_rollback { shift->storage->txn_rollback }
 
 =head2 clone
 
@@ -344,7 +375,7 @@ sub clone {
   return $clone;
 }
 
-=item populate($moniker, \@data);
+=head2 populate($moniker, \@data);
 
 Populates the source registered with the given moniker with the supplied data.
 @data should be a list of listrefs, the first containing column names, the
@@ -370,7 +401,7 @@ sub populate {
   }
 }
 
-=item throw_exception
+=head2 throw_exception
 
 Defaults to using Carp::Clan to report errors from user perspective.