X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FAttribute.pm;h=4e3eb090d4dc2a7aac92f2eaa1615a6097a3c4c6;hb=148b469742669e1a506538200f624dcdaeeb510a;hp=ca93efeef8f6e7d70034db6a852ae1080660c2ec;hpb=716c57656450dae12aff9302ad1c3a3d6e8138d3;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index ca93efe..4e3eb09 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -7,7 +7,7 @@ use warnings; use Carp 'confess'; use Scalar::Util 'blessed', 'reftype', 'weaken'; -our $VERSION = '0.11'; +our $VERSION = '0.12'; our $AUTHORITY = 'cpan:STEVAN'; sub meta { @@ -34,6 +34,11 @@ sub new { $options{init_arg} = $name if not exists $options{init_arg}; + (is_default_a_coderef(\%options)) + || confess("References are not allowed as default values, you must ". + "wrap then in a CODE reference (ex: sub { [] } and not [])") + if exists $options{default} && ref $options{default}; + bless { name => $name, accessor => $options{accessor},