我目前正在将构建器方法委托给扩展我的基类之一的所有对象。我面临的问题是我需要所有对象要么读取自身的属性,要么传入一个值。
# In Role:
has 'const_string' => (
isa => 'Str',
is => 'ro',
default => 'test',
);
has 'attr' => (
isa => 'Str',
is => 'ro',
builder => '_builder',
);
requires '_builder';
# In extending object - desired 1
sub _builder {
my ($self) = shift;
# $self contains $self->const_string
}
# In extending object - desired 2
sub _builder {
my ($arg1, $arg2) = @_;
# $args can be passed somehow?
}
这是目前可能的还是我将不得不以其他方式做到这一点?