From: Yuval Kogman Date: Tue, 8 Jan 2008 11:50:02 +0000 (+0000) Subject: overload::Overloaded calls are superflous, overlaod::StrVal works on every value... X-Git-Tag: 0_35~19^2~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6361ccf5f1b303625c83d93a3099ce51b5a74c95;p=gitmo%2FMoose.git overload::Overloaded calls are superflous, overlaod::StrVal works on every value type --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index bad7518..23324b2 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -248,9 +248,7 @@ sub initialize_instance_slot { $type_constraint->name . ") with '" . (defined $val - ? (blessed($val) && overload::Overloaded($val) - ? overload::StrVal($val) - : $val) + ? overload::StrVal($val) : 'undef') . "'"; } @@ -284,11 +282,7 @@ sub set_value { . $type_constraint->name . ") with " . (defined($value) - ? ("'" . - (blessed($value) && overload::Overloaded($value) - ? overload::StrVal($value) - : $value) - . "'") + ? ("'" . overload::StrVal($value) . "'") : "undef") if defined($value); } diff --git a/lib/Moose/Meta/Method/Accessor.pm b/lib/Moose/Meta/Method/Accessor.pm index 22c85f2..cc610cd 100644 --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@ -129,7 +129,7 @@ sub _inline_check_constraint { $type_constraint->(%s) || confess "Attribute (" . $attr_name . ") does not pass the type constraint (" . $type_constraint_name . ") with " - . (defined(%s) ? (Scalar::Util::blessed(%s) && overload::Overloaded(%s) ? overload::StrVal(%s) : %s) : "undef") + . (defined(%s) ? overload::StrVal(%s) : "undef") if defined(%s); EOF } @@ -175,7 +175,7 @@ sub _inline_check_lazy { $code .= ' $default = $type_constraint_obj->coerce($default);'."\n" if $attr->should_coerce; $code .= ' ($type_constraint->($default))' . ' || confess "Attribute (" . $attr_name . ") does not pass the type constraint ("' . - ' . $type_constraint_name . ") with " . (defined($default) ? (Scalar::Util::blessed($default) && overload::Overloaded($default) ? overload::StrVal($default) : $default) : "undef")' . + ' . $type_constraint_name . ") with " . (defined($default) ? overload::StrVal($default) : "undef")' . ' if defined($default);' . "\n" . ' ' . $slot_access . ' = $default; ' . "\n"; } diff --git a/lib/Moose/Meta/Method/Constructor.pm b/lib/Moose/Meta/Method/Constructor.pm index 581e753..9b1bb6d 100644 --- a/lib/Moose/Meta/Method/Constructor.pm +++ b/lib/Moose/Meta/Method/Constructor.pm @@ -210,7 +210,7 @@ sub _generate_type_constraint_check { $type_constraint_cv . '->(' . $value_name . ')' . "\n\t" . '|| confess "Attribute (' . $attr->name . ') does not pass the type constraint (' . $attr->type_constraint->name - . ') with " . (defined(' . $value_name . ') ? (Scalar::Util::blessed(' . $value_name . ') && overload::Overloaded(' . $value_name . ') ? overload::StrVal(' . $value_name . ') : ' . $value_name . ') : "undef");' + . ') with " . (defined(' . $value_name . ') ? overload::StrVal(' . $value_name . ') : "undef");' ); }