line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::add_field; |
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
84687
|
use Catmandu::Sane; |
|
19
|
|
|
|
|
50
|
|
|
19
|
|
|
|
|
148
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
19
|
|
|
19
|
|
146
|
use Moo; |
|
19
|
|
|
|
|
59
|
|
|
19
|
|
|
|
|
113
|
|
8
|
19
|
|
|
19
|
|
8460
|
use Catmandu::Util::Path qw(as_path); |
|
19
|
|
|
|
|
45
|
|
|
19
|
|
|
|
|
1124
|
|
9
|
19
|
|
|
19
|
|
135
|
use namespace::clean; |
|
19
|
|
|
|
|
51
|
|
|
19
|
|
|
|
|
133
|
|
10
|
19
|
|
|
19
|
|
11954
|
use Catmandu::Fix::Has; |
|
19
|
|
|
|
|
53
|
|
|
19
|
|
|
|
|
162
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has value => (fix_arg => 1, default => sub {undef}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_fixer { |
18
|
105
|
|
|
105
|
|
1018
|
my ($self) = @_; |
19
|
105
|
|
|
|
|
492
|
as_path($self->path)->creator($self->value); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=pod |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Catmandu::Fix::add_field - add or change the value of a HASH key or ARRAY index |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Contrary to C<set_field>, this will create the intermediate structures |
35
|
|
|
|
|
|
|
if they are missing. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Add a new field 'foo' with value 2 |
40
|
|
|
|
|
|
|
add_field(foo, 2) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Change the value of 'foo' to 'bar 123' |
43
|
|
|
|
|
|
|
add_field(foo, 'bar 123') |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Create a deeply nested key |
46
|
|
|
|
|
|
|
add_field(my.deep.nested.key, hi) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# If the second argument is omitted the field has a null value |
49
|
|
|
|
|
|
|
add_field(foo) |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SEE ALSO |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L<Catmandu::Fix> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |