| 1 | package Catmandu::Fix::Condition::all_equal; | ||
| 2 | |||
| 3 | 1 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | our $VERSION = '1.0201_02'; | |
| 6 | |||
| 7 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use Catmandu::Fix::Has; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 1 | has path => (fix_arg => 1); | |
| 12 | 1 | has value => (fix_arg => 1); | |
| 13 | |||
| 14 | 1 | with 'Catmandu::Fix::Condition::SimpleAllTest'; | |
| 15 | |||
| 16 | sub emit_test { | ||
| 17 | 2 | ▶ | my ($self, $var) = @_; |
|
Subroutine
emit_test: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 18 | 2 | my $value = $self->value; | |
| 19 | 2 | "is_value(${var}) && ${var} eq '$value'"; | |
| 20 | } | ||
| 21 | |||
| 22 | 1 | 1; | |
| 23 | |||
| 24 | __END__ | ||
| 25 | |||
| 26 | =pod | ||
| 27 | |||
| 28 | =head1 NAME | ||
| 29 | |||
| 30 | Catmandu::Fix::Condition::all_equal - Execute fixes when all path values equal a string value | ||
| 31 | |||
| 32 | =head1 DESCRIPTION | ||
| 33 | |||
| 34 | This fix is meant as an simple alternative to L<Catmandu::Fix::Condition::all_match>. | ||
| 35 | No regular expressions are involved. String are compared using the regular | ||
| 36 | operator 'eq'. | ||
| 37 | |||
| 38 | =head1 SYNOPSIS | ||
| 39 | |||
| 40 | # all_equal(X,Y) is true when value of X == 'Y' | ||
| 41 | if all_equal('year','2018') | ||
| 42 | add_field('my.funny.title','true') | ||
| 43 | end | ||
| 44 | |||
| 45 | # all_equal(X,Y) is false when value of X == 'Ya' | ||
| 46 | |||
| 47 | =head1 SEE ALSO | ||
| 48 | |||
| 49 | L<Catmandu::Fix> , L<Catmandu::Fix::Condition::any_equal> | ||
| 50 | |||
| 51 | =cut | ||