From: Peter Rabbitson Date: Sun, 15 May 2016 15:01:32 +0000 (+0200) Subject: Ensure the component_class override require()s its value in a pipeline X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dd1853390485b141d014a59aa550fba966493784;p=dbsrgits%2FDBIx-Class-Historic.git Ensure the component_class override require()s its value in a pipeline --- diff --git a/lib/DBIx/Class/AccessorGroup.pm b/lib/DBIx/Class/AccessorGroup.pm index 01a5559..5ac4651 100644 --- a/lib/DBIx/Class/AccessorGroup.pm +++ b/lib/DBIx/Class/AccessorGroup.pm @@ -46,7 +46,11 @@ sub get_component_class { }; sub set_component_class { - shift->set_inherited(@_); + $_[0]->set_inherited($_[1], $_[2]); + + # trigger a load for the case of $foo->component_accessor("bar")->new + $_[0]->get_component_class($_[1]) + if defined wantarray; } 1; diff --git a/t/05components.t b/t/05components.t index b6f2c3e..335fb06 100644 --- a/t/05components.t +++ b/t/05components.t @@ -6,10 +6,16 @@ use Test::More; use DBICTest; -use DBICTest::ForeignComponent; + +{ + package DBICTest::SomeResult; + use base 'DBIx::Class::Core'; + __PACKAGE__->table("boguz"); +} # Tests if foreign component was loaded by calling foreign's method -ok( DBICTest::ForeignComponent->foreign_test_method, 'foreign component' ); +ok( ! $INC{"DBICTest/ForeignComponent.pm"}, "DBICTest::ForeignComponent not yet loaded" ); +ok( DBICTest::SomeResult->result_class("DBICTest::ForeignComponent")->foreign_test_method, 'foreign component loaded correctly' ); # Test for inject_base to filter out duplicates { package DBICTest::_InjectBaseTest;