Change the signature of verify_type_constraint_error [IMCOMPATIBLE]
gfx [Sat, 19 Dec 2009 07:10:36 +0000 (16:10 +0900)]
lib/Mouse/Meta/Attribute.pm
lib/Mouse/Meta/Method/Accessor.pm
lib/Mouse/Meta/Method/Constructor.pm

index 98dd81b..c4b749e 100644 (file)
@@ -238,13 +238,17 @@ sub verify_against_type_constraint {
     return 1 if !$type_constraint;
     return 1 if $type_constraint->check($value);
 
-    $self->verify_type_constraint_error($self->name, $value, $type_constraint);
+    $self->verify_type_constraint_error($value, $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));
+    my($self, $value, $type) = @_;
+
+    $self->throw_error(
+        sprintf q{Attribute (%s) does not pass the type constraint because: %s},
+            $self->name,
+            $type->get_message($value),
+    );
 }
 
 sub coerce_constraint { # DEPRECATED
index 46cbbc1..be8d9ff 100755 (executable)
@@ -49,7 +49,7 @@ sub _generate_accessor_any{
             $accessor .= 
                 "\n".
                 '$compiled_type_constraint->('.$value.') or
-                    $attribute->verify_type_constraint_error($name, '.$value.', $constraint);' . "\n";
+                    $attribute->verify_type_constraint_error('.$value.', $constraint);' . "\n";
         }
 
         # if there's nothing left to do for the attribute we can return during
@@ -96,7 +96,7 @@ sub _generate_accessor_any{
             $accessor .= "my \$tmp = $value;\n";
 
             $accessor .= "\$compiled_type_constraint->(\$tmp)";
-            $accessor .= " || \$attribute->verify_type_constraint_error(\$name, \$tmp, \$constraint);\n";
+            $accessor .= " || \$attribute->verify_type_constraint_error(\$tmp, \$constraint);\n";
             $accessor .= "$slot = \$tmp;\n";
         }
         else{
index a96977d..deed6b0 100644 (file)
@@ -77,7 +77,7 @@ sub _generate_processattrs {
         my $post_process = '';
         if(defined $type_constraint){
             $post_process .= "\$checks[$index]->($instance_slot)";
-            $post_process .= "  or $attr_var->verify_type_constraint_error(q{$key}, $instance_slot, $constraint_var);\n";
+            $post_process .= "  or $attr_var->verify_type_constraint_error($instance_slot, $constraint_var);\n";
         }
         if($is_weak_ref){
             $post_process .= "Scalar::Util::weaken($instance_slot) if ref $instance_slot;\n";