From: Christian Walde Date: Mon, 2 Jul 2012 16:14:16 +0000 (+0200) Subject: sanity check code for default providers is now more readable X-Git-Tag: v0.091012~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=30613a658f1d3d6b5e9fc85b4c3b13d3b3a3d47e;p=gitmo%2FMoo.git sanity check code for default providers is now more readable --- diff --git a/lib/Method/Generate/Accessor.pm b/lib/Method/Generate/Accessor.pm index 01acab8..88e38a3 100644 --- a/lib/Method/Generate/Accessor.pm +++ b/lib/Method/Generate/Accessor.pm @@ -45,14 +45,9 @@ sub generate_method { } if (exists $spec->{default}) { my $default = $spec->{default}; - unless (ref $default) { - die "Invalid default $default"; - } - if (ref $default ne 'CODE') { - unless (eval { \&$default }) { - die "Invalid default $default"; - } - } + # default can be either a coderef or an overloaded object + die "Invalid default $default" unless ref $default + and ( ref $default eq 'CODE' or eval { \&$default } ); } my %methods;