From: Dave Rolsky Date: Mon, 1 Sep 2008 22:41:56 +0000 (+0000) Subject: Handle the case where $instance ends up resolving to a class name, not X-Git-Tag: 0.57~32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbeacd38c90812d602c262cb67dec8f128061be9;p=gitmo%2FMoose.git Handle the case where $instance ends up resolving to a class name, not an object, in _inline_check_lazy. This is a bit of a hack, but the whole immutable thing is a giant hack, so I don't think it's too bad. Alternately, we could add a new _inline_class_name method and just call that, and I could override it for class attributes. --- diff --git a/lib/Moose/Meta/Method/Accessor.pm b/lib/Moose/Meta/Method/Accessor.pm index 8da980d..b39b782 100644 --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@ -170,7 +170,7 @@ sub _inline_check_lazy { $code .= ' my $default;'."\n". ' if(my $builder = '.$instance.'->can($attr->builder)){ '."\n". ' $default = '.$instance.'->$builder; '. "\n } else {\n" . - ' confess(Scalar::Util::blessed('.$instance.')." does not support builder method '. + ' confess((Scalar::Util::blessed('.$instance.') || '.$instance.')." does not support builder method '. '\'".$attr->builder."\' for attribute \'" . $attr->name . "\'");'. "\n }"; } $code .= ' $default = $type_constraint_obj->coerce($default);'."\n" if $attr->should_coerce; @@ -192,7 +192,7 @@ sub _inline_check_lazy { $code .= ' if (my $builder = '.$instance.'->can($attr->builder)) { ' . "\n" . ' ' . $self->_inline_init_slot($attr, $instance, $slot_access, ($instance . '->$builder')) . "\n } else {\n" . - ' confess(Scalar::Util::blessed('.$instance.')." does not support builder method '. + ' confess((Scalar::Util::blessed('.$instance.') || '.$instance.')." does not support builder method '. '\'".$attr->builder."\' for attribute \'" . $attr->name . "\'");'. "\n }"; } else {