Refactor FileHash to expect named arguments

This commit is contained in:
Dan Church 2023-07-20 13:04:52 -05:00
parent 31fe372e09
commit 15c466e581
Signed by: h3xx
GPG key ID: EA2BF379CD2CDBD0
2 changed files with 5 additions and 12 deletions

View file

@ -22,16 +22,9 @@ sub new {
}
sub add {
my $self = shift;
my (@files, $callback);
if (ref $_[0] eq 'HASH') {
# Called method like { files => [] }
my %opts = %{$_[0]};
@files = @{$opts{files}};
$callback = $opts{callback};
} else {
@files = @_;
}
my ($self, %args) = @_;
my @files = @{$args{files}};
my $callback = $args{callback};
foreach my $file (@files) {
unless (ref $file eq 'Directory::Simplify::File') {
$file = Directory::Simplify::File->new($file);

View file

@ -230,10 +230,10 @@ MAIN: {
}
};
}
$filehash->add({
$filehash->add(
files => \@files,
callback => $cb,
});
);
print STDERR "done.\n"
if $verbose;