mirror of
https://codeberg.org/h3xx/simplify_static_dir
synced 2024-08-14 23:57:24 +00:00
Refactor FileHash to expect named arguments
This commit is contained in:
parent
31fe372e09
commit
15c466e581
2 changed files with 5 additions and 12 deletions
|
@ -22,16 +22,9 @@ sub new {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add {
|
sub add {
|
||||||
my $self = shift;
|
my ($self, %args) = @_;
|
||||||
my (@files, $callback);
|
my @files = @{$args{files}};
|
||||||
if (ref $_[0] eq 'HASH') {
|
my $callback = $args{callback};
|
||||||
# Called method like { files => [] }
|
|
||||||
my %opts = %{$_[0]};
|
|
||||||
@files = @{$opts{files}};
|
|
||||||
$callback = $opts{callback};
|
|
||||||
} else {
|
|
||||||
@files = @_;
|
|
||||||
}
|
|
||||||
foreach my $file (@files) {
|
foreach my $file (@files) {
|
||||||
unless (ref $file eq 'Directory::Simplify::File') {
|
unless (ref $file eq 'Directory::Simplify::File') {
|
||||||
$file = Directory::Simplify::File->new($file);
|
$file = Directory::Simplify::File->new($file);
|
||||||
|
|
|
@ -230,10 +230,10 @@ MAIN: {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
$filehash->add({
|
$filehash->add(
|
||||||
files => \@files,
|
files => \@files,
|
||||||
callback => $cb,
|
callback => $cb,
|
||||||
});
|
);
|
||||||
print STDERR "done.\n"
|
print STDERR "done.\n"
|
||||||
if $verbose;
|
if $verbose;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue