add_components() doesn't prepend base when comp. prefixed with +
Robert Sedlacek [Thu, 2 Mar 2006 19:16:30 +0000 (19:16 +0000)]
Changes
lib/DBIx/Class.pm
lib/DBIx/Class/Componentised.pm
t/05components.t [new file with mode: 0644]
t/lib/DBICTest/ForeignComponent.pm [new file with mode: 0644]
t/lib/DBICTest/ForeignComponent/TestComp.pm [new file with mode: 0644]

diff --git a/Changes b/Changes
index 0438e98..57f845f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 Revision history for DBIx::Class
 
+        - add_components() doesn't prepend base when comp. prefixed with +
         - $schema->deploy
         - HAVING support
         - prefetch for has_many
index 4e90838..98054c0 100644 (file)
@@ -166,6 +166,8 @@ Scotty Allen <scotty@scottyallen.com>
 
 sc_
 
+Robert Sedlacek <phaylon@dunkelheit.at>
+
 =head1 LICENSE
 
 You may distribute this code under the same terms as Perl itself.
index d4a6641..737e24b 100644 (file)
@@ -20,7 +20,7 @@ sub inject_base {
 sub load_components {
   my $class = shift;
   my $base = $class->component_base_class;
-  my @comp = map { "${base}::$_" } grep { $_ !~ /^#/ } @_;
+  my @comp = map { /^\+(.*)$/ ? $1 : "${base}::$_" } grep { $_ !~ /^#/ } @_;
   $class->_load_components(@comp);
   Class::C3::reinitialize();
 }
diff --git a/t/05components.t b/t/05components.t
new file mode 100644 (file)
index 0000000..57bebd5
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+
+use lib qw(t/lib);
+use DBICTest::ForeignComponent;
+
+plan tests => 1;
+
+#   Tests if foreign component was loaded by calling foreign's method
+ok( DBICTest::ForeignComponent->foreign_test_method, 'foreign component' );
+
diff --git a/t/lib/DBICTest/ForeignComponent.pm b/t/lib/DBICTest/ForeignComponent.pm
new file mode 100644 (file)
index 0000000..a701459
--- /dev/null
@@ -0,0 +1,10 @@
+#   belongs to t/05components.t
+package DBICTest::ForeignComponent;
+use warnings;
+use strict;
+
+use base qw/ DBIx::Class /;
+
+__PACKAGE__->load_components( qw/ +DBICTest::ForeignComponent::TestComp / );
+
+1;
diff --git a/t/lib/DBICTest/ForeignComponent/TestComp.pm b/t/lib/DBICTest/ForeignComponent/TestComp.pm
new file mode 100644 (file)
index 0000000..ce024ba
--- /dev/null
@@ -0,0 +1,8 @@
+#   belongs to t/05components.t
+package DBICTest::ForeignComponent::TestComp;
+use warnings;
+use strict;
+
+sub foreign_test_method { 1 }
+
+1;