Revision history for Perl extension Moose
+0.29
+ * Moose::Meta::Attribute
+ -Fix error message on missing builder method (groditi)
+
+ * Moose::Meta::Method::Accessor
+ -Fix error message on missing builder method (groditi)
+
+ * t/
+ -Add test to check for the correct error message when
+ builder method is missing (groditi)
+
0.28 Tues. Nov. 13, 2007
- 0.27 packaged incorrectly (groditi)
use strict;
use warnings;
-our $VERSION = '0.28';
+our $VERSION = '0.29';
our $AUTHORITY = 'cpan:STEVAN';
use Scalar::Util 'blessed', 'reftype';
=head2 Moose Extensions
The L<MooseX::> namespace is the official place to find Moose extensions.
-There are a number of these modules out on CPAN right now the best way to
-find them is to search for MooseX:: on search.cpan.org.
+There are a number of these modules out on CPAN right now the best way to
+find them is to search for MooseX:: on search.cpan.org.
=head1 BUILDING CLASSES WITH MOOSE
use Carp 'confess';
use overload ();
-our $VERSION = '0.13';
+our $VERSION = '0.14';
our $AUTHORITY = 'cpan:STEVAN';
use Moose::Meta::Method::Accessor;
$val = $self->default($instance);
$value_is_set = 1;
} elsif ($self->has_builder) {
- my $builder = $self->builder;
- if($builder = $instance->can($builder)){
+ if(my $builder = $instance->can($self->builder)){
$val = $instance->$builder;
$value_is_set = 1;
} else {
- confess(blessed($instance)." does not support builder method '$builder' for attribute '" . $self->name . "'");
+ confess(blessed($instance)." does not support builder method '".$self->builder."' for attribute '" . $self->name . "'");
}
}
}
$self->set_value($instance, $default);
}
if ( $self->has_builder ){
- my $builder = $self->builder;
- if($builder = $instance->can($builder)){
+ if(my $builder = $instance->can($self->builder)){
$self->set_value($instance, $instance->$builder);
} else {
- confess(blessed($instance)." does not support builder method '$builder' for attribute '" . $self->name . "'");
+ confess(blessed($instance)." does not support builder method '".$self->builder."' for attribute '" . $self->name . "'");
}
} else {
$self->set_value($instance, undef);
use Carp 'confess';
-our $VERSION = '0.06';
+our $VERSION = '0.07';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Moose::Meta::Method',
' my $default; '.
' $default = $attr->default(' . $inv . ') if $attr->has_default;' .
' if ( $attr->has_builder ) { '.
- ' my $builder = $attr->builder;'.
- ' if($builder = '.$inv.'->can($builder)){ '.
+ ' if(my $builder = '.$inv.'->can($attr->builder)){ '.
' $default = '.$inv.'->$builder; '.
' } else { '.
- ' confess(blessed('.$inv.')." does not support builder method \'$builder\' for attribute \'" . $attr->name . "\'");'.
+ ' confess(Scalar::Util::blessed('.$inv.')." does not support builder method \'".$attr->builder."\' for attribute \'" . $attr->name . "\'");'.
' }'.
' }'.
($attr->should_coerce
return 'unless ( ' . $slot_exists . ') {' .
' if ($attr->has_default) { ' . $slot_access . ' = $attr->default(' . $inv . '); }' .
' elsif ($attr->has_builder) { '.
- ' my $builder = $attr->builder; ' .
- ' if($builder = '.$inv.'->can($builder)){ '.
+ ' if(my $builder = '.$inv.'->can($attr->builder)){ '.
' ' . $slot_access . ' = ' . $inv . '->$builder; '.
' } else { '.
- ' confess(blessed('.$inv.')." does not support builder method \'$builder\' for attribute \'" . $attr->name . "\'");'.
+ ' confess(Scalar::Util::blessed('.$inv.')." does not support builder method \'".$attr->builder."\' for attribute \'" . $attr->name . "\'");'.
' }'.
' } else { ' .$slot_access . ' = undef; } '.
'}';
use strict;
use warnings;
-use Test::More tests => 40;
+use Test::More tests => 41;
use Test::Exception;
BEGIN {
has 'foo' => ( lazy_build => 1, is => 'ro');
has '_foo' => ( lazy_build => 1, is => 'ro');
+ has 'fool' => ( lazy_build => 1, is => 'ro');
sub _build_foo { return "works" };
sub _build__foo { return "works too" };
}
ok(!$instance->_has_foo, "noo _foo value yet");
is($instance->foo, 'works', "foo builder works");
is($instance->_foo, 'works too', "foo builder works too");
+ throws_ok { $instance->fool }
+ qr/Test::LazyBuild::Attribute does not support builder method \'_build_fool\' for attribute \'fool\'/,
+ "Correct error when a builder method is not present";
}