Hello,
I would like to have a "delete_matching" option, which when coupled with
"allow_extra", would allow easy currying of parameters, for example:
# in class P
sub new {
my $class = shift;
my %params_for_parent = validate_with(
params => \@_,
spec => {
child_class => ...,
foo => ...,
},
allow_extra => 1,
delete_matching => 1);
# do stuff with foo
# pass on unused parameters
return $params_for_parent{child_class}->new(@_);
}
# in class C extends P
sub new {
my $class = shift;
my %params_for_child = validate_with(
params => \@_, # doesn't have foo
spec => {
bar => ...,
});
# do stuff with self and bar
return bless $self, $class;
}
I don't really like the "delete_matching" name but I haven't found
anything better, if you have a suggestion? Maybe a single
"curry_unused" option instead, that would set "allow_extra" and do the
job of "delete_matching".
Finer control should remain possible in case both P and C want to use "foo".
If the above change is OK with you, I'm willing to start working on it.