->wrap is documented as a constructor, so it should expect a class name as the first...
[gitmo/Class-MOP.git] / lib / Class / MOP.pm
index 4587469..819aa60 100644 (file)
@@ -31,7 +31,7 @@ BEGIN {
     *check_package_cache_flag = \&mro::get_pkg_gen;
 }
 
-our $VERSION   = '0.67';
+our $VERSION   = '0.71';
 our $XS_VERSION = $VERSION;
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';    
@@ -125,8 +125,7 @@ sub load_first_existing_class {
         }
     }
 
-    return get_metaclass_by_name($found) || $found
-        if $found;
+    return $found if $found;
 
     confess join(
         "\n",
@@ -155,7 +154,8 @@ sub _try_load_one_class {
 }
 
 sub load_class {
-    load_first_existing_class($_[0]);
+    my $class = load_first_existing_class($_[0]);
+    return get_metaclass_by_name($class) || $class;
 }
 
 sub _is_valid_class_name {
@@ -173,7 +173,7 @@ sub _is_valid_class_name {
 sub is_class_loaded {
     my $class = shift;
 
-    return 0 if ref($class) || !defined($class) || !length($class);
+    return 0 unless _is_valid_class_name($class);
 
     # walk the symbol table tree to avoid autovififying
     # \*{${main::}{"Foo::"}} == \*main::Foo::
@@ -950,9 +950,8 @@ B<NOTE: DO NOT USE THIS FUNCTION, IT IS FOR INTERNAL USE ONLY!>
 Given a list of class names, this function will attempt to load each
 one in turn.
 
-If it finds a class it can load, it will return that class's
-metaclass. If none of the classes can be loaded, it will throw an
-exception.
+If it finds a class it can load, it will return that class' name.
+If none of the classes can be loaded, it will throw an exception.
 
 =back