| 1 | package Catmandu::Fix::Condition::all_match; | ||
| 2 | |||
| 3 | 4 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 4 | our $VERSION = '1.0201_02'; | |
| 6 | |||
| 7 | 4 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 4 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 4 | ▶ | use Catmandu::Fix::Has; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 4 | has path => (fix_arg => 1); | |
| 12 | 4 | has pattern => (fix_arg => 1); | |
| 13 | |||
| 14 | 4 | with 'Catmandu::Fix::Condition::SimpleAllTest'; | |
| 15 | |||
| 16 | sub emit_test { | ||
| 17 | 8 | ▶ | my ($self, $var, $parser) = @_; |
|
Subroutine
emit_test: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 18 | 8 | "is_value(${var}) && ${var} =~ " . $parser->emit_match($self->pattern); | |
| 19 | } | ||
| 20 | |||
| 21 | 4 | 1; | |
| 22 | |||
| 23 | __END__ | ||
| 24 | |||
| 25 | =pod | ||
| 26 | |||
| 27 | =head1 NAME | ||
| 28 | |||
| 29 | Catmandu::Fix::Condition::all_match - only execute fixes if all path values match the given regex | ||
| 30 | |||
| 31 | =head1 SYNOPSIS | ||
| 32 | |||
| 33 | # uppercase the value of field 'foo' if all members of 'oogly' have the value 'doogly' | ||
| 34 | if all_match(oogly.*, "doogly") | ||
| 35 | upcase(foo) # foo => 'BAR' | ||
| 36 | end | ||
| 37 | |||
| 38 | =head1 SEE ALSO | ||
| 39 | |||
| 40 | L<Catmandu::Fix> | ||
| 41 | |||
| 42 | =cut | ||