From: gfx Date: Mon, 12 Oct 2009 07:29:02 +0000 (+0900) Subject: Tidy X-Git-Tag: 0.37_06~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=4331a3f99a23bda694da1b38df4614bfb73ecd22 Tidy --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 1b2fb03..1d4c15b 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -263,15 +263,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 +278,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 +286,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 diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index ab75b2b..563a208 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -188,7 +188,7 @@ sub _initialize_object{ my $key = $attribute->name; if (defined($from) && exists($args->{$from})) { - $object->{$key} = $attribute->_coerce_and_verify($args->{$from}); + $object->{$key} = $attribute->_coerce_and_verify($args->{$from}, $object); weaken($object->{$key}) if ref($object->{$key}) && $attribute->is_weak_ref; @@ -206,7 +206,7 @@ sub _initialize_object{ : ref($default) eq 'CODE' ? $object->$default() : $default; - $object->{$key} = $attribute->_coerce_and_verify($value, $object);; + $object->{$key} = $attribute->_coerce_and_verify($value, $object); weaken($object->{$key}) if ref($object->{$key}) && $attribute->is_weak_ref;