X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FObject.pm;h=fcfaf6b094d4e6fcdc75968bae432bff1a9bb7d3;hb=11ac534bdfe4aab1f8bfb575769dee68f456c1d9;hp=8c36df30f5753f3c674b74ca46b314cd5944504a;hpb=626cd940635e34f4a742f69de6354ecd83333e66;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 8c36df3..fcfaf6b 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -16,9 +16,10 @@ sub new { for my $attribute ($class->meta->compute_all_applicable_attributes) { my $from = $attribute->init_arg; my $key = $attribute->name; - my $default; if (defined($from) && exists($args->{$from})) { + $args->{$from} = $attribute->coerce_constraint($args->{$from}) + if $attribute->should_coerce; $attribute->verify_type_constraint($args->{$from}) if $attribute->has_type_constraint; @@ -42,6 +43,8 @@ sub new { ? $default->() : $default; + $value = $attribute->coerce_constraint($value) + if $attribute->should_coerce; $attribute->verify_type_constraint($value) if $attribute->has_type_constraint;