has '+members' => (isa => 'ArrayRef[Debbugs::Correspondent]');
-around BUILDARGS => sub {
- my $orig = shift;
- my $class = shift;
-
- my %args;
- if (@_==1 and ref($_[0]) eq 'HASH') {
- %args = %{$_[0]};
- } else {
- %args = @_;
- }
- $args{members} //= [];
- if (exists $args{correspondent}) {
- push @{$args{members}},
- _member_constructor(correspondent => $args{correspondent},
- hash_slice(%args,qw(schema constructor_args)),
- );
- delete $args{bugs};
+sub BUILD {
+ my $self = shift;
+ my $args = shift;
+ if (exists $args->{correspondent}) {
+ $self->
+ add($self->_member_constructor(correspondent =>
+ $args->{correspondent}));
}
- return $class->$orig(%args);
-};
+}
+
sub _member_constructor {
# handle being called $self->_member_constructor;
- my $self;
- if ((@_ % 2) == 1) {
- $self = shift;
- }
+ my $self = shift;
my %args = @_;
my @return;
- my $schema;
- if (exists $args{schema}) {
- $schema = $args{schema};
- } elsif (defined $self and $self->has_schema) {
- $schema = $self->schema;
- }
for my $corr (make_list($args{correspondent})) {
push @return,
Debbugs::Correspondent->new(name => $corr,
- defined $schema?(schema => $schema):(),
+ $self->schema_argument,
);
}
return @return;
my $orig = shift;
my $self = shift;
my @members =
- _member_constructor(correspondent => [@_],
- $self->has_schema?(schema => $self->schema):(),
- constructor_args => $self->constructor_args,
- );
+ $self->_member_constructor(correspondent => [@_],
+ $self->schema_argument,
+ );
return $self->$orig(@members);
};