Skip to content

Commit

Permalink
CEF parser: enable 021_cef_cvotes.t tests but some perl warnings remain
Browse files Browse the repository at this point in the history
  • Loading branch information
ikluft committed Aug 30, 2023
1 parent 1fb6791 commit b1b370c
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 138 deletions.
19 changes: 16 additions & 3 deletions src/perl/prefvote/lib/PrefVote/Core/Input/CEF.pm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ sub init
}

# initialize parameters
foreach my $key ( keys %args ) {
$self->{_in_keys} = [ keys %args ];
foreach my $key ( @{$self->{_in_keys}} ) {
$self->{$key} = $args{$key};
}

Expand Down Expand Up @@ -314,10 +315,22 @@ sub xfer
{
my ($self, $recipient) = @_;
my @skipped;

# hashify list of input parameter keys so we know not to warn since they usually exist in destination
my %in_keys = grep { return ($_ => 1) } @{$self->{_in_keys}};

# transfer object fields to destination, except internal-only or those already existing in desetination
foreach my $key (keys %$self) {
if (substr($key, 0, 1) eq "_") {
# skip transfer for internal-only data prefixed with underscore "_"
next;
}
if (exists $recipient->{$key}) {
# do not overwrite data in the recipient object - warn about it
push @skipped, $key
# only warn about a field conflict if it wasn't in the input paramerters
if (not exists $in_keys{$key}) {
# do not overwrite data in the recipient object - warn about it
push @skipped, $key;
}
} else {
# copy item
$recipient->{$key} = $self->{$key};
Expand Down
Loading

0 comments on commit b1b370c

Please sign in to comment.