From: Hans Dieter Pearcey Date: Fri, 8 May 2009 03:13:14 +0000 (-0400) Subject: remove all uses of load_class's return value; use class_of instead, where appropriate X-Git-Tag: 0.78~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c8d9f1e23325b02e0ef484d2201280b1073d205d;p=gitmo%2FMoose.git remove all uses of load_class's return value; use class_of instead, where appropriate --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 4c9b450..04c5797 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -620,7 +620,8 @@ sub _canonicalize_handles { } } else { - my $role_meta = Class::MOP::load_class($handles); + Class::MOP::load_class($handles); + my $role_meta = Class::MOP::class_of($handles); (blessed $role_meta && $role_meta->isa('Moose::Meta::Role')) || $self->throw_error("Unable to canonicalize the 'handles' option with $handles because its metaclass is not a Moose::Meta::Role", data => $handles); diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 25a9fa6..d7bdf32 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -246,7 +246,8 @@ sub superclasses { my $self = shift; my @supers = @_; foreach my $super (@supers) { - my $meta = Class::MOP::load_class($super); + Class::MOP::load_class($super); + my $meta = Class::MOP::class_of($super); Moose->throw_error("You cannot inherit from a Moose Role ($super)") if $meta && $meta->isa('Moose::Meta::Role') } diff --git a/lib/Moose/Util.pm b/lib/Moose/Util.pm index 5616f9b..a1cba21 100644 --- a/lib/Moose/Util.pm +++ b/lib/Moose/Util.pm @@ -94,9 +94,10 @@ sub _apply_all_roles { my $roles = Data::OptList::mkopt( [@_] ); foreach my $role (@$roles) { - my $meta = Class::MOP::load_class( $role->[0] ); + Class::MOP::load_class( $role->[0] ); + my $meta = Class::MOP::class_of( $role->[0] ); - unless ($meta->isa('Moose::Meta::Role') ) { + unless ($meta && $meta->isa('Moose::Meta::Role') ) { require Moose; Moose->throw_error( "You can only consume roles, " . $role->[0] diff --git a/t/030_roles/035_anonymous_roles.t b/t/030_roles/035_anonymous_roles.t index 75cd304..0d36658 100644 --- a/t/030_roles/035_anonymous_roles.t +++ b/t/030_roles/035_anonymous_roles.t @@ -31,5 +31,5 @@ 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(Class::MOP::load_class(Moose::Meta::Role->create_anon_role->name), "creating an anonymous role satisifes load_class"); +ok(Class::MOP::class_of(Moose::Meta::Role->create_anon_role->name), "creating an anonymous role satisifes class_of");