Skip Menu |

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

Report information
The Basics
Id: 96312
Status: resolved
Priority: 0/
Queue: MooseX-Enumeration

People
Owner: perl [...] toby.ink
Requestors: jmac [...] jmac.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.004
Fixed in: (no value)



Subject: Generated "is_" methods don't trigger lazy attributes' builders
Calling the generated "is_$value" methods on the object does not appear to trigger the builder method when the underlying attribute is both lazy and unset. Code that illustrates this: package Stoplight; use Moose; use Moose::Util::TypeConstraints; use MooseX::Enumeration; enum 'StoplightColor', [qw( red yellow green ) ]; has 'color' => ( is => 'ro', isa => 'StoplightColor', traits => [ 'Enumeration' ], handles => 1, lazy_build => 1, ); sub _build_color { return 'green'; } package main; my $stoplight = Stoplight->new; sub go_status { my ( $stoplight ) = @_; return "Are we good to go? " . ( $stoplight->is_green? "Yes!\n" : "No.\n" ); } # I'd expect calling the "is" method to act like an ordinary Moose read- # accessor, triggering the lazy attribute's build method. But it doesn't. print go_status( $stoplight ); # Now we'll try it again, calling that ordinary read-accessor first. $stoplight->color; print go_status( $stoplight );
How have I only just spotted this bug report? This is a pretty serious issue. I'll try to get a fix out for it in a few days.
Fixed in 0.005.