bump version to 0.73_01
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor.pm
index 93df0ac..bb3a7a4 100644 (file)
@@ -4,7 +4,7 @@ package Moose::Meta::Method::Accessor;
 use strict;
 use warnings;
 
-our $VERSION   = '0.72_01';
+our $VERSION   = '0.73_01';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -52,7 +52,7 @@ sub _generate_accessor_method_inline {
     . 'if (scalar(@_) >= 2) {' . "\n"
         . $self->_inline_copy_value . "\n"
         . $self->_inline_check_required . "\n"
-        . $self->_inline_check_coercion . "\n"
+        . $self->_inline_check_coercion($value_name) . "\n"
         . $self->_inline_check_constraint($value_name) . "\n"
         . $self->_inline_store($inv, $value_name) . "\n"
         . $self->_inline_trigger($inv, $value_name) . "\n"
@@ -75,7 +75,7 @@ sub _generate_writer_method_inline {
     . $self->_inline_pre_body(@_)
     . $self->_inline_copy_value
     . $self->_inline_check_required
-    . $self->_inline_check_coercion
+    . $self->_inline_check_coercion($value_name)
     . $self->_inline_check_constraint($value_name)
     . $self->_inline_store($inv, $value_name)
     . $self->_inline_post_body(@_)
@@ -132,10 +132,12 @@ sub _inline_check_constraint {
 }
 
 sub _inline_check_coercion {
-    my $attr = (shift)->associated_attribute;
+    my ($self, $value) = @_;
+
+    my $attr = $self->associated_attribute;
     
     return '' unless $attr->should_coerce;
-    return '$val = $attr->type_constraint->coerce($_[1]);'
+    return "$value = \$attr->type_constraint->coerce($value);";
 }
 
 sub _inline_check_required {
@@ -172,11 +174,8 @@ sub _inline_check_lazy {
                          '        ' . $self->_inline_throw_error(q{sprintf "%s does not support builder method '%s' for attribute '%s'", ref(} . $instance . ') || '.$instance.', $attr->builder, $attr->name') .
                          ';'. "\n    }";
             }
-            $code .= '    $default = $type_constraint_obj->coerce($default);'."\n"  if $attr->should_coerce;
-            $code .= '    ($type_constraint->($default))' .
-                     '            || ' . $self->_inline_throw_error('"Attribute (" . $attr_name . ") does not pass the type constraint ("' .
-                     '           . $type_constraint_name . ") with " . (defined($default) ? overload::StrVal($default) : "undef")' ) . ';' 
-                     . "\n";
+            $code .= $self->_inline_check_coercion('$default') . "\n";
+            $code .= $self->_inline_check_constraint('$default') . "\n";
             $code .= '    ' . $self->_inline_init_slot($attr, $instance, $slot_access, '$default') . "\n";
         } 
         else {