Skip Menu |

This queue is for tickets about the MooseX-ClassAttribute CPAN distribution.

Report information
The Basics
Id: 36808
Status: resolved
Priority: 0/
Queue: MooseX-ClassAttribute

People
Owner: Nobody in particular
Requestors: dan.harbin [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.04
Fixed in: 0.05



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! }