allow multiple classless sources to be registered without dying
Jason May [Wed, 29 Apr 2009 15:18:11 +0000 (15:18 +0000)]
lib/DBIx/Class/Schema.pm
t/63register_source.t [new file with mode: 0644]

index 5cb37fb..71faab7 100644 (file)
@@ -1280,6 +1280,7 @@ sub _register_source {
   $self->source_registrations(\%reg);
 
   return if ($params->{extra});
+  return unless defined($rs_class) && $rs_class->can('result_source_instance');
 
   my %map = %{$self->class_mappings};
   if (
diff --git a/t/63register_source.t b/t/63register_source.t
new file mode 100644 (file)
index 0000000..6951962
--- /dev/null
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+
+use Test::Exception tests => 1;
+use lib qw(t/lib);
+use DBICTest;
+use DBICTest::Schema;
+use DBIx::Class::ResultSource::Table;
+
+my $schema = DBICTest->init_schema();
+
+my $foo = DBIx::Class::ResultSource::Table->new({ name => "foo" });
+my $bar = DBIx::Class::ResultSource::Table->new({ name => "bar" });
+
+lives_ok {
+    $schema->register_source(foo => $foo);
+    $schema->register_source(bar => $bar);
+} 'multiple classless sources can be registered';