Add xt/external to MANIFEST.SKIP
[gitmo/Mouse.git] / lib / Mouse / Meta / Attribute.pm
index 1b2fb03..71a2bbd 100644 (file)
@@ -214,17 +214,21 @@ sub interpolate_class{
     my @traits;
     if(my $traits_ref = delete $args->{traits}){
 
-        for (my $i = 0; $i < @{$traits_ref}; $i++) {
-            my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1);
+        local $@;
+        eval{
+            for (my $i = 0; $i < @{$traits_ref}; $i++) {
+                my $trait = Mouse::Util::resolve_metaclass_alias(Attribute => $traits_ref->[$i], trait => 1);
 
-            next if $class->does($trait);
+                next if $class->does($trait);
 
-            push @traits, $trait;
+                push @traits, $trait;
 
-            # are there options?
-            push @traits, $traits_ref->[++$i]
-                if ref($traits_ref->[$i+1]);
-        }
+                # are there options?
+                push @traits, $traits_ref->[++$i]
+                    if ref($traits_ref->[$i+1]);
+            }
+        };
+        warn "Fatal error in traits: $@" if _MOUSE_VERBOSE;
 
         if (@traits) {
             $class = Mouse::Meta::Class->create_anon_class(
@@ -248,7 +252,7 @@ sub canonicalize_args{ # DEPRECATED
     return %args;
 }
 
-sub create {
+sub create { # DEPRECATED
     my ($self, $class, $name, %args) = @_;
 
     Carp::cluck("$self->create has been deprecated."
@@ -263,15 +267,12 @@ sub _coerce_and_verify {
     my($self, $value, $instance) = @_;
 
     my $type_constraint = $self->{type_constraint};
-
-    return $value if !$type_constraint;
+    return $value if !defined $type_constraint;
 
     if ($self->should_coerce && $type_constraint->has_coercion) {
         $value = $type_constraint->coerce($value);
     }
 
-    return $value if $type_constraint->check($value);
-
     $self->verify_against_type_constraint($value);
 
     return $value;
@@ -281,7 +282,7 @@ sub verify_against_type_constraint {
     my ($self, $value) = @_;
 
     my $type_constraint = $self->{type_constraint};
-    return 1 if !$type_constraint;;
+    return 1 if !$type_constraint;
     return 1 if $type_constraint->check($value);
 
     $self->verify_type_constraint_error($self->name, $value, $type_constraint);
@@ -289,7 +290,8 @@ sub verify_against_type_constraint {
 
 sub verify_type_constraint_error {
     my($self, $name, $value, $type) = @_;
-    $self->throw_error("Attribute ($name) does not pass the type constraint because: " . $type->get_message($value));
+    $self->throw_error("Attribute ($name) does not pass the type constraint because: "
+        . $type->get_message($value));
 }
 
 sub coerce_constraint { # DEPRECATED
@@ -464,6 +466,10 @@ __END__
 
 Mouse::Meta::Attribute - The Mouse attribute metaclass
 
+=head1 VERSION
+
+This document describes Mouse version 0.39
+
 =head1 METHODS
 
 =head2 C<< new(%options) -> Mouse::Meta::Attribute >>