From: Jason May Date: Wed, 29 Apr 2009 15:18:11 +0000 (+0000) Subject: allow multiple classless sources to be registered without dying X-Git-Tag: v0.08102~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5dfe40b8aebffcd8e873ea2f6fb71ab7d6b755f8;p=dbsrgits%2FDBIx-Class.git allow multiple classless sources to be registered without dying --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 5cb37fb..71faab7 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -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 index 0000000..6951962 --- /dev/null +++ b/t/63register_source.t @@ -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';