From: Vyacheslav Matyukhin Date: Wed, 6 Jun 2012 20:26:12 +0000 (+0400) Subject: check default using \&{} X-Git-Tag: v0.091010~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3970e6f8c9d26634794010c24950a0fde5a9223e;p=gitmo%2FMoo.git check default using \&{} --- diff --git a/lib/Method/Generate/Accessor.pm b/lib/Method/Generate/Accessor.pm index 87f70eb..7056200 100644 --- a/lib/Method/Generate/Accessor.pm +++ b/lib/Method/Generate/Accessor.pm @@ -45,16 +45,14 @@ sub generate_method { } if (exists $spec->{default}) { my $default = $spec->{default}; - require Scalar::Util; - unless ( - ref $default - and ( - Scalar::Util::reftype $default eq 'CODE' - or Scalar::Util::blessed $default and $default->can('(&{}') - ) - ) { + unless (ref $default) { die "Invalid default $default"; } + if (ref $default ne 'CODE') { + unless (eval { \&$default }) { + die "Invalid default $default"; + } + } } my %methods;