Obecnie deleguję metodę konstruktora do wszystkich obiektów, które rozszerzają jedną z moich klas bazowych. Problem, z którym się borykam, polega na tym, że potrzebuję wszystkich obiektów, aby albo odczytały jakiś atrybut lub przekazały wartość.Argument dla podprocedury konstruktora w obiekcie łosia
# 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?
}
Czy jest to obecnie możliwe, czy też będę musiał to zrobić w inny sposób?
mam problemy ze zrozumieniem dokładnie co to jest starasz się osiągnąć, może to wyjaśnić z punktu widzenia konsumenta? –