Still need to deprecate the functions themselves and remove the tests for them.
package inc::RequireAuthorDeps;
+use Class::Load qw(load_class);
use Moose;
use Try::Tiny;
}
for my $mod (grep { $_ ne 'perl' } $req->required_modules) {
- Class::MOP::load_class($mod);
+ load_class($mod);
}
}
use Class::MOP::MiniTrait;
use Carp 'confess';
+use Class::Load 'is_class_loaded', 'load_class';
use Scalar::Util 'blessed', 'reftype', 'weaken';
use Sub::Name 'subname';
use Try::Tiny;
}
return $class_name
- if Class::MOP::is_class_loaded($class_name);
+ if is_class_loaded($class_name);
# If the metaclass is a subclass of CMOP::Class which has had
# metaclass roles applied (via Moose), then we want to make sure
my $constructor_class = $args{constructor_class};
- Class::MOP::load_class($constructor_class);
+ load_class($constructor_class);
my $constructor = $constructor_class->new(
options => \%args,
my $destructor_class = $args{destructor_class};
- Class::MOP::load_class($destructor_class);
+ load_class($destructor_class);
return unless $destructor_class->is_needed($self);
use strict;
use warnings;
+use Class::Load qw(load_class);
+
sub apply {
my ( $to_class, $trait ) = @_;
for ( grep { !ref } $to_class, $trait ) {
- Class::MOP::load_class($_);
+ load_class($_);
$_ = Class::MOP::Class->initialize($_);
}
use Scalar::Util 'blessed';
use Carp 'confess';
+use Class::Load 'is_class_loaded';
+
use Moose::Deprecated;
use Moose::Exporter;
my $meta_name = exists $args{meta_name} ? $args{meta_name} : 'meta';
Moose->throw_error("The Metaclass $metaclass must be loaded. (Perhaps you forgot to 'use $metaclass'?)")
- unless Class::MOP::is_class_loaded($metaclass);
+ unless is_class_loaded($metaclass);
Moose->throw_error("The Metaclass $metaclass must be a subclass of Moose::Meta::Class.")
unless $metaclass->isa('Moose::Meta::Class');
use strict;
use warnings;
+use Class::Load qw(is_class_loaded);
use Class::MOP;
use List::MoreUtils qw( first_index uniq );
use Moose::Util::MetaRole;
my $exporting_package = shift;
if ( !exists $EXPORT_SPEC{$exporting_package} ) {
- my $loaded = Class::MOP::is_class_loaded($exporting_package);
+ my $loaded = is_class_loaded($exporting_package);
die "Package in also ($exporting_package) does not seem to "
. "use Moose::Exporter"
use strict;
use warnings;
-use Class::MOP ();
use B ();
+use Class::Load qw(is_class_loaded load_class);
use Scalar::Util 'blessed', 'weaken';
use List::MoreUtils 'any';
use Try::Tiny;
}
}
- Class::MOP::load_class($handles);
+ load_class($handles);
my $role_meta = Class::MOP::class_of($handles);
(blessed $role_meta && $role_meta->isa('Moose::Meta::Role'))
sub _find_delegate_metaclass {
my $self = shift;
if (my $class = $self->_isa_metadata) {
- unless ( Class::MOP::is_class_loaded($class) ) {
+ unless ( is_class_loaded($class) ) {
$self->throw_error(
sprintf(
'The %s attribute is trying to delegate to a class which has not been loaded - %s',
return Class::MOP::Class->initialize($class);
}
elsif (my $role = $self->_does_metadata) {
- unless ( Class::MOP::is_class_loaded($class) ) {
+ unless ( is_class_loaded($class) ) {
$self->throw_error(
sprintf(
'The %s attribute is trying to delegate to a role which has not been loaded - %s',
package Moose::Meta::Attribute::Native;
+use Class::Load qw(load_class);
+
my @trait_names = qw(Bool Counter Number String Array Hash Code);
for my $trait_name (@trait_names) {
$meta->add_method(register_implementation => sub {
# resolve_metatrait_alias will load classes anyway, but throws away
# their error message; we WANT to die if there's a problem
- Class::MOP::load_class($trait_class);
+ load_class($trait_class);
return $trait_class;
});
}
package Moose::Meta::Attribute::Native::Trait;
use Moose::Role;
+use Class::Load qw(load_class);
use List::MoreUtils qw( any uniq );
use Moose::Util::TypeConstraints;
use Moose::Deprecated;
. $self->_native_type . '::'
. $suffix;
- Class::MOP::load_class($role);
+ load_class($role);
return Moose::Meta::Class->create_anon_class(
superclasses =>
[ $self->accessor_metaclass, $self->delegation_metaclass ],
use strict;
use warnings;
+use Class::Load qw(load_class);
use Class::MOP;
-
use Carp qw( confess );
use Data::OptList;
use List::Util qw( first );
my $supers = Data::OptList::mkopt(\@_);
foreach my $super (@{ $supers }) {
my ($name, $opts) = @{ $super };
- Class::MOP::load_class($name, $opts);
+ load_class($name, $opts);
my $meta = Class::MOP::class_of($name);
$self->throw_error("You cannot inherit from a Moose Role ($name)")
if $meta && $meta->isa('Moose::Meta::Role')
my $class = ref $self ? $self->error_class : "Moose::Error::Default";
- Class::MOP::load_class($class);
+ load_class($class);
$class->new(
Carp::caller_info($args{depth}),
my $class = ref $self ? $self->error_class : "Moose::Error::Default";
- Class::MOP::load_class($class);
+ load_class($class);
# don't check inheritance here - the intention is that the class needs
# to provide a non-inherited inlining method, because falling back to
use warnings;
use metaclass;
+use Class::Load qw(load_class);
use Scalar::Util 'blessed';
use Carp 'confess';
use Devel::GlobalDestruction 'in_global_destruction';
$application_class = $self->application_to_instance_class;
}
- Class::MOP::load_class($application_class);
+ load_class($application_class);
if ( exists $args{'-excludes'} ) {
# I wish we had coercion here :)
use warnings;
use metaclass;
+use Class::Load qw(load_class);
use Scalar::Util 'blessed';
use base 'Moose::Meta::Role';
sub apply_params {
my ($self, $role_params) = @_;
- Class::MOP::load_class($self->application_role_summation_class);
+ load_class($self->application_role_summation_class);
$self->application_role_summation_class->new(
role_params => $role_params,
fallback => 1;
use Carp qw(confess);
+use Class::Load qw(load_class);
use Eval::Closure;
use Scalar::Util qw(blessed refaddr);
use Sub::Name qw(subname);
# have to load it late like this, since it uses Moose itself
my $can_partialdump = try {
# versions prior to 0.14 had a potential infinite loop bug
- Class::MOP::load_class('Devel::PartialDump', { -version => 0.14 });
+ load_class('Devel::PartialDump', { -version => 0.14 });
1;
};
if ($can_partialdump) {
use Scalar::Util 'blessed';
use Carp 'croak';
+use Class::Load 'is_class_loaded';
use Sub::Exporter;
my $meta_name = exists $args{meta_name} ? $args{meta_name} : 'meta';
Moose->throw_error("The Metaclass $metaclass must be loaded. (Perhaps you forgot to 'use $metaclass'?)")
- unless Class::MOP::is_class_loaded($metaclass);
+ unless is_class_loaded($metaclass);
Moose->throw_error("The Metaclass $metaclass must be a subclass of Moose::Meta::Role.")
unless $metaclass->isa('Moose::Meta::Role');
use strict;
use warnings;
+use Class::Load qw(load_class load_first_existing_class);
use Data::OptList;
use Params::Util qw( _STRING );
use Sub::Exporter;
$meta = $role->[0];
}
else {
- Class::MOP::load_class( $role->[0] , $role->[1] );
+ load_class( $role->[0] , $role->[1] );
$meta = find_meta( $role->[0] );
}
return unless @role_metas;
- Class::MOP::load_class($applicant)
+ load_class($applicant)
unless blessed($applicant)
|| Class::MOP::class_of($applicant);
$type, $metaclass_name, $options{trait}
);
- my $loaded_class = Class::MOP::load_first_existing_class(
+ my $loaded_class = load_first_existing_class(
$possible_full_name,
$metaclass_name
);
use strict;
use warnings;
+use Class::Load qw( is_class_loaded );
use List::MoreUtils ();
use Scalar::Util qw( blessed looks_like_number reftype );
subtype 'ClassName'
=> as 'Str'
- => where { Class::MOP::is_class_loaded($_) }
+ => where { is_class_loaded($_) }
# the long Str tests are redundant here
- => inline_as { 'Class::MOP::is_class_loaded(' . $_[1] . ')' };
+ => inline_as { 'Class::Load::is_class_loaded(' . $_[1] . ')' };
subtype 'RoleName'
=> as 'ClassName'
use warnings;
use Carp 'confess';
+use Class::Load 'load_class';
use Scalar::Util 'blessed';
use Try::Tiny;
unless ( defined $metaclass ) {
$metaclass = "Class::MOP::Class";
} else {
- Class::MOP::load_class($metaclass);
+ load_class($metaclass);
}
($metaclass->isa('Class::MOP::Class'))
# make sure the custom metaclasses get loaded
foreach my $key (grep { /_(?:meta)?class$/ } keys %options) {
unless ( ref( my $class = $options{$key} ) ) {
- Class::MOP::load_class($class)
+ load_class($class)
}
}
use strict;
use warnings;
-use Class::MOP;
+use Class::Load qw(load_class);
BEGIN {
my $package;
$package = $_[1] || 'Class';
if ($package =~ /^\+/) {
$package =~ s/^\+//;
- Class::MOP::load_class($package);
+ load_class($package);
}
}
use Filter::Simple sub { s/^/package $package;\nuse Moose;use Moose::Util::TypeConstraints;\n/; }
use Test::More;
use Test::Fatal;
-use Class::MOP;
+use Class::Load qw( is_class_loaded load_class );
use lib catdir($FindBin::Bin, 'lib');
## These are all tests which are derived from the Tree::Binary test suite
## ----------------------------------------------------------------------------
-ok(!Class::MOP::is_class_loaded('BinaryTree'), '... the binary tree class is not loaded');
+ok(!is_class_loaded('BinaryTree'), '... the binary tree class is not loaded');
is( exception {
- Class::MOP::load_class('BinaryTree');
+ load_class('BinaryTree');
}, undef, '... loaded the BinaryTree class without dying' );
-ok(Class::MOP::is_class_loaded('BinaryTree'), '... the binary tree class is now loaded');
+ok(is_class_loaded('BinaryTree'), '... the binary tree class is now loaded');
## ----------------------------------------------------------------------------
## t/10_Tree_Binary_test.t
use Test::More;
+use Class::Load qw(is_class_loaded);
+
BEGIN {
use_ok('Class::MOP');
use_ok('Class::MOP::Mixin');
'Class::MOP::Class::Immutable::Class::MOP::Class' => Class::MOP::Class::Immutable::Class::MOP::Class->meta,
);
-ok( Class::MOP::is_class_loaded($_), '... ' . $_ . ' is loaded' )
+ok( is_class_loaded($_), '... ' . $_ . ' is loaded' )
for keys %METAS;
for my $meta (values %METAS) {
use Test::More;
use Test::Fatal;
+use Class::Load qw( is_class_loaded load_class );
use Class::MOP;
use Tie::Scalar;
{
my $x = tie my $value, 'Tie::StdScalar', 'Class::MOP';
- is( exception { Class::MOP::load_class($value) }, undef, 'load_class(tied scalar)' );
+ is( exception { load_class($value) }, undef, 'load_class(tied scalar)' );
$value = undef;
$x->STORE('Class::MOP'); # reset
is( exception {
- ok Class::MOP::is_class_loaded($value);
+ ok is_class_loaded($value);
}, undef, 'is_class_loaded(tied scalar)' );
$value = undef;
use Test::More;
-use Class::MOP;
+use Class::Load qw(is_class_loaded);
use lib catdir($FindBin::Bin, 'lib');
my $meta = Foo->meta;
isa_ok($meta, 'MyMetaClass', '... Correct metaclass');
-ok(Class::MOP::is_class_loaded('MyMetaClass'), '... metaclass loaded');
+ok(is_class_loaded('MyMetaClass'), '... metaclass loaded');
is($meta->attribute_metaclass, 'MyMetaClass::Attribute', '... Correct attribute metaclass');
-ok(Class::MOP::is_class_loaded('MyMetaClass::Attribute'), '... attribute metaclass loaded');
+ok(is_class_loaded('MyMetaClass::Attribute'), '... attribute metaclass loaded');
is($meta->instance_metaclass, 'MyMetaClass::Instance', '... Correct instance metaclass');
-ok(Class::MOP::is_class_loaded('MyMetaClass::Instance'), '... instance metaclass loaded');
+ok(is_class_loaded('MyMetaClass::Instance'), '... instance metaclass loaded');
is($meta->method_metaclass, 'MyMetaClass::Method', '... Correct method metaclass');
-ok(Class::MOP::is_class_loaded('MyMetaClass::Method'), '... method metaclass loaded');
+ok(is_class_loaded('MyMetaClass::Method'), '... method metaclass loaded');
done_testing;
use warnings;
use Test::More;
+use Class::Load 'load_class';
use Test::Requires 'Data::Visitor';
use Test::Requires 'PadWalker';
use Try::Tiny;
my $can_partialdump = try {
- Class::MOP::load_class('Devel::PartialDump', { -version => 0.14 }); 1;
+ load_class('Devel::PartialDump', { -version => 0.14 }); 1;
};
{
use Test::More;
use Moose ();
+use Class::Load qw(is_class_loaded);
+
my $role = Moose::Meta::Role->create_anon_role(
attributes => {
is_worn => {
like($role->name, qr/^Moose::Meta::Role::__ANON__::SERIAL::\d+$/, "");
ok($role->is_anon_role, "the role knows it's anonymous");
-ok(Class::MOP::is_class_loaded(Moose::Meta::Role->create_anon_role->name), "creating an anonymous role satisifes is_class_loaded");
+ok(is_class_loaded(Moose::Meta::Role->create_anon_role->name), "creating an anonymous role satisifes is_class_loaded");
ok(Class::MOP::class_of(Moose::Meta::Role->create_anon_role->name), "creating an anonymous role satisifes class_of");
done_testing;