line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::all_equal; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1245
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
14
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
8
|
2
|
|
|
2
|
|
700
|
use Catmandu::Util qw(is_value); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
104
|
|
9
|
2
|
|
|
2
|
|
15
|
use namespace::clean; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
12
|
|
10
|
2
|
|
|
2
|
|
603
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
18
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has value => (fix_arg => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition::Builder::Simple'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_value_tester { |
18
|
4
|
|
|
4
|
|
56
|
my ($self) = @_; |
19
|
4
|
|
|
|
|
22
|
my $value = $self->value; |
20
|
|
|
|
|
|
|
sub { |
21
|
11
|
|
|
11
|
|
21
|
my $v = $_[0]; |
22
|
11
|
50
|
|
|
|
222
|
is_value($v) && $v eq $value; |
23
|
4
|
|
|
|
|
23
|
}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__END__ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Catmandu::Fix::Condition::all_equal - Execute fixes when all path values equal a string value |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This fix is meant as an simple alternative to L<Catmandu::Fix::Condition::all_match>. |
39
|
|
|
|
|
|
|
No regular expressions are involved. String are compared using the regular |
40
|
|
|
|
|
|
|
operator 'eq'. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# all_equal(X,Y) is true when value of X == 'Y' |
45
|
|
|
|
|
|
|
if all_equal('year','2018') |
46
|
|
|
|
|
|
|
add_field('my.funny.title','true') |
47
|
|
|
|
|
|
|
end |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# all_equal(X,Y) is false when value of X == 'Ya' |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SEE ALSO |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L<Catmandu::Fix> , L<Catmandu::Fix::Condition::any_equal> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |