X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FAccessor.pm;h=db3903c778de053ce90a7d5bb321a6d56d4a179a;hb=a15d1371334de8874a74618597d0c1995fdca276;hp=3ae91a845d329cfece2473fb0ec80318bb67b512;hpb=7b133c927969b2e9233a51c6be5caed54c88915e;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method/Accessor.pm b/lib/Mouse/Meta/Method/Accessor.pm index 3ae91a8..db3903c 100755 --- a/lib/Mouse/Meta/Method/Accessor.pm +++ b/lib/Mouse/Meta/Method/Accessor.pm @@ -15,7 +15,7 @@ sub _install_accessor{ my $should_deref = $attribute->should_auto_deref; my $should_coerce = $attribute->should_coerce; - my $compiled_type_constraint = $constraint ? $constraint->{_compiled_type_constraint} : undef; + my $compiled_type_constraint = $constraint ? $constraint->_compiled_type_constraint : undef; my $self = '$_[0]'; my $key = sprintf q{"%s"}, quotemeta $name; @@ -171,22 +171,22 @@ sub _install_handles { foreach my $handle_name (keys %handles) { my $method_to_call = $handles{$handle_name}; - my $code = sub { - my $instance = shift; - my $proxy = $instance->$reader(); - - my $error = !defined($proxy) ? ' is not defined' - : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')} - : undef; - if ($error) { - $instance->meta->throw_error( - "Cannot delegate $handle_name to $method_to_call because " - . "the value of " - . $attribute->name - . $error, - ); - } - $proxy->$method_to_call(@_); + my $code = sub { + my $instance = shift; + my $proxy = $instance->$reader(); + + my $error = !defined($proxy) ? ' is not defined' + : ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')} + : undef; + if ($error) { + $instance->meta->throw_error( + "Cannot delegate $handle_name to $method_to_call because " + . "the value of " + . $attribute->name + . $error + ); + } + $proxy->$method_to_call(@_); }; $class->add_method($handle_name => $code); }