Subject: | Using a builder method on a class attribute causes a runtime error |
Using a builder method on a class attribute causes a runtime error. See
the attached code for a test case.
It is possible to workaround using a fully qualified package name:
builder => "MyClass::_build_attr"
But then if you attempt to use $self in the builder method, it will give
the same runtime error.
Perl version: 5.8.5
Subject: | classattr.pl |
#!/usr/bin/env perl
use strict;
use warnings;
package MyClass;
{
use Moose;
use MooseX::ClassAttribute;
class_has 'classattr' => (
is => 'rw',
isa => 'Str',
lazy => 1,
builder => '_build_attr',
);
sub _build_attr {
my $self = shift;
return "Hello, world!";
}
}
package main;
{
my $instance = MyClass->new();
print $instance->classattr, "\n"; # should print: Hello, world!
}