package
Data::Object::Array::Func::EachKey;
use
5.014;
use
strict;
use
warnings;
use
Data::Object::Class;
our
$VERSION
=
'2.05'
;
# VERSION
# BUILD
has
arg1
=> (
is
=>
'ro'
,
isa
=>
'ArrayLike'
,
req
=> 1
);
has
arg2
=> (
is
=>
'ro'
,
isa
=>
'CodeLike'
,
req
=> 1
);
has
args
=> (
is
=>
'ro'
,
isa
=>
'ArrayRef[Any]'
,
opt
=> 1
);
# METHODS
sub
execute {
my
(
$self
) =
@_
;
my
$results
= [];
my
(
$data
,
$code
,
@args
) =
$self
->
unpack
;
for
(
my
$i
= 0;
$i
<
@$data
;
$i
++) {
my
$index
=
$i
;
my
$value
=
$data
->[
$i
];
push
@$results
,
$code
->(
$index
,
@args
);
}
return
$results
;
}
sub
mapping {
return
(
'arg1'
,
'arg2'
,
'@args'
);
}
1;