$value_is_set = 1;
}
elsif ($self->has_builder) {
- if (my $builder = $instance->can($self->builder)){
- $val = $instance->$builder;
- $value_is_set = 1;
- }
- else {
- confess(blessed($instance)." does not support builder method '".$self->builder."' for attribute '" . $self->name . "'");
- }
+ $val = $self->_call_builder($instance);
+ $value_is_set = 1;
}
}
if ref $val && $self->is_weak_ref;
}
+sub _call_builder {
+ my ( $self, $instance ) = @_;
+
+ my $builder = $self->builder();
+
+ return $instance->$builder()
+ if $instance->can( $self->builder );
+
+ confess( blessed($instance)
+ . " does not support builder method '"
+ . $self->builder
+ . "' for attribute '"
+ . $self->name
+ . "'" );
+}
+
## Slot management
# FIXME:
if ($self->has_default) {
$value = $self->default($instance);
} elsif ( $self->has_builder ) {
- if (my $builder = $instance->can($self->builder)){
- $value = $instance->$builder;
- }
- else {
- confess(blessed($instance)
- . " does not support builder method '"
- . $self->builder
- . "' for attribute '"
- . $self->name
- . "'");
- }
- }
+ $value = $self->_call_builder($instance);
+ }
if ($self->has_type_constraint) {
my $type_constraint = $self->type_constraint;
$value = $type_constraint->coerce($value)