# pure-perl (FatPack-able) libs
'Class::Accessor::Grouped' => '0.10012',
'Class::C3::Componentised' => '1.0009',
- 'Class::Inspector' => '1.24',
'Context::Preserve' => '0.01',
'Data::Page' => '2.00',
'Devel::GlobalDestruction' => '0.09',
use warnings;
use base 'DBIx::Class';
use Sub::Name ();
-use Class::Inspector;
+use Package::Stash ();
warn "DBIx::Class::ResultSetManager never left experimental status and
has now been DEPRECATED. This module will be deleted in 09000 so please
my $cache = $self->_attr_cache;
return if keys %$cache == 0;
- foreach my $meth (@{Class::Inspector->methods($self) || []}) {
+ foreach my $meth (keys %{ { map
+ { $_ => 1 }
+ map
+ { Package::Stash->new($_)->list_all_symbols("CODE") }
+ @{ mro::get_linear_isa( ref $self || $self ) }
+ } } ) {
+ # *DO NOT* rely on P::S returning crefs in reverse mro order
+ # but instead ask the mro to redo the lookup
+ # This codepath is extremely old, miht as well keep it running
+ # as-is with no room for surprises
my $attrs = $cache->{$self->can($meth)};
next unless $attrs;
if ($attrs->[0] eq 'ResultSet') {
use Test::More;
use lib 't/cdbi/testlib';
+use DBICTest::Util 'class_seems_loaded';
use Director;
# Test that has_many() will load the foreign class
-require Class::Inspector;
-ok !Class::Inspector->loaded( 'Film' );
+ok ! class_seems_loaded('Film'), 'Start non-loaded';
ok eval { Director->has_many( films => 'Film' ); 1; } or diag $@;
my $shan_hua = Director->create({
use base 'Exporter';
our @EXPORT_OK = qw(
- dbg stacktrace
+ dbg stacktrace class_seems_loaded
local_umask slurp_bytes tmpdir find_co_root rm_rf
visit_namespaces PEEPEENESS
check_customcond_args
return $visited_count;
}
+#
+# Replicate the *heuristic* (important!!!) implementation found in various
+# forms within Class::Load / Module::Inspector / Class::C3::Componentised
+#
+sub class_seems_loaded ($) {
+
+ croak "Function expects a class name as plain string (no references)"
+ unless defined $_[0] and not length ref $_[0];
+
+ no strict 'refs';
+
+ return 1 if defined ${"$_[0]::VERSION"};
+
+ return 1 if @{"$_[0]::ISA"};
+
+ return 1 if $INC{ (join ('/', split ('::', $_[0]) ) ) . '.pm' };
+
+ ( !!*{"$_[0]::$_"}{CODE} ) and return 1
+ for keys %{"$_[0]::"};
+
+ return 0;
+}
+
1;
use strict;
use warnings;
use Test::More;
-use Class::Inspector ();
use DBICTest;
+use DBICTest::Util 'class_seems_loaded';
is(DBICTest::Schema->source('Artist')->resultset_class, 'DBICTest::BaseResultSet', 'default resultset class');
-ok(!Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class not loaded');
+ok(! class_seems_loaded('DBICNSTest::ResultSet::A'), 'custom resultset class not loaded');
DBICTest::Schema->source('Artist')->resultset_class('DBICNSTest::ResultSet::A');
-ok(!Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class not loaded on SET');
+ok(! class_seems_loaded('DBICNSTest::ResultSet::A'), 'custom resultset class not loaded on SET');
is(DBICTest::Schema->source('Artist')->resultset_class, 'DBICNSTest::ResultSet::A', 'custom resultset class set');
-ok(Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class loaded on GET');
+ok(class_seems_loaded('DBICNSTest::ResultSet::A'), 'custom resultset class loaded on GET');
my $schema = DBICTest->init_schema;
my $resultset = $schema->resultset('Artist')->search;
use DBICTest;
use DBIx::Class::_Util 'sigwarn_silencer';
-use Class::Inspector;
+use DBICTest::Util 'class_seems_loaded';
BEGIN {
package TestPackage::A;
# Test ensure_class_found
ok( $schema->ensure_class_found('DBIx::Class::Schema'),
'loaded package DBIx::Class::Schema was found' );
-ok( !Class::Inspector->loaded('DBICTest::FakeComponent'),
+ok( ! class_seems_loaded('DBICTest::FakeComponent'),
'DBICTest::FakeComponent not loaded yet' );
ok( $schema->ensure_class_found('DBICTest::FakeComponent'),
'package DBICTest::FakeComponent was found' );
-ok( !Class::Inspector->loaded('DBICTest::FakeComponent'),
+ok( ! class_seems_loaded('DBICTest::FakeComponent'),
'DBICTest::FakeComponent not loaded by ensure_class_found()' );
ok( $schema->ensure_class_found('TestPackage::A'),
'anonymous package TestPackage::A found' );
}
# Test ensure_class_loaded
-ok( Class::Inspector->loaded('TestPackage::A'), 'anonymous package exists' );
+ok( class_seems_loaded('TestPackage::A'), 'anonymous package exists' );
eval { $schema->ensure_class_loaded('TestPackage::A'); };
ok( !$@, 'ensure_class_loaded detected an anon. class' );
eval { $schema->ensure_class_loaded('FakePackage::B'); };
like( $@, qr/Can't locate/,
'ensure_class_loaded threw exception for nonexistent class' );
-ok( !Class::Inspector->loaded('DBICTest::FakeComponent'),
+ok( ! class_seems_loaded('DBICTest::FakeComponent'),
'DBICTest::FakeComponent not loaded yet' );
eval { $schema->ensure_class_loaded('DBICTest::FakeComponent'); };
ok( !$@, 'ensure_class_loaded detected an existing but non-loaded class' );
-ok( Class::Inspector->loaded('DBICTest::FakeComponent'),
+ok( class_seems_loaded('DBICTest::FakeComponent'),
'DBICTest::FakeComponent now loaded' );
{
Sub::Defer::undefer_all();
-# can't use Class::Inspector for the mundane parts as it does not
-# distinguish imports from anything else, what a crock of...
-# Moose is not always available either - hence just do it ourselves
-
my $seen; #inheritance means we will see the same method multiple times
for my $mod (@modules) {