use warnings;
use base qw/Class::Accessor::Grouped/;
+use Scalar::Util qw/weaken/;
+use namespace::clean;
-our %successfully_loaded_components;
+my $successfully_loaded_components;
sub get_component_class {
my $class = $_[0]->get_inherited($_[1]);
- if (defined $class and ! $successfully_loaded_components{$class}) {
+
+ if (defined $class and ! $successfully_loaded_components->{$class} ) {
$_[0]->ensure_class_loaded($class);
- $successfully_loaded_components{$class}++; # only increment if the load succeeded
+
+ no strict 'refs';
+ $successfully_loaded_components->{$class}
+ = ${"${class}::__LOADED__BY__DBIC__CAG__COMPONENT_CLASS__"}
+ = do { \(my $anon = 'loaded') };
+ weaken($successfully_loaded_components->{$class});
}
+
$class;
};
is($schema->resultset("Artist")->search(), 3, "Three artists returned");
} 'Custom cursor autoloaded';
+SKIP: {
+ eval { require Class::Unload }
+ or skip 'component_class reentrancy test requires Class::Unload', 1;
+
+ Class::Unload->unload('DBICTest::Cursor');
+
+ lives_ok {
+ is($schema->resultset("Artist")->search(), 3, "Three artists still returned");
+ } 'Custom cursor auto re-loaded';
+}
+
done_testing;