line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::set_hash; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
107411
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
17
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
843
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
53
|
|
9
|
1
|
|
|
1
|
|
7
|
use namespace::clean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
10
|
1
|
|
|
1
|
|
749
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has values => (fix_arg => 'collect', default => sub {[]}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_fixer { |
18
|
5
|
|
|
5
|
|
48
|
my ($self) = @_; |
19
|
5
|
|
|
|
|
14
|
my $values = $self->values; |
20
|
5
|
|
|
3
|
|
61
|
as_path($self->path)->setter(sub {+{@$values}}); |
|
3
|
|
|
|
|
55
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
__END__ |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=pod |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Catmandu::Fix::set_hash - add or change the value of a HASH key or ARRAY index to a hash |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Contrary to C<add_field>, this will not create the intermediate structures |
36
|
|
|
|
|
|
|
if they are missing. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Change the value of 'foo' to an empty hash |
41
|
|
|
|
|
|
|
set_hash(foo) |
42
|
|
|
|
|
|
|
# Or a hash with initial contents |
43
|
|
|
|
|
|
|
set_hash(a: b, c: d) |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
L<Catmandu::Fix> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |