line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
89325
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
410
|
use Catmandu::Util qw(is_array_ref); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
5
|
1
|
|
|
1
|
|
7
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
4
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
292
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
8
|
1
|
|
|
1
|
|
628
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has old_path => (fix_arg => 1); |
12
|
|
|
|
|
|
|
has new_path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has key_name => (fix_arg => 1); |
14
|
|
|
|
|
|
|
has value_name => (fix_arg => 1); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my ($self) = @_; |
17
|
|
|
|
|
|
|
my $key_name = $self->key_name; |
18
|
3
|
|
|
3
|
|
26
|
my $val_name = $self->value_name; |
19
|
3
|
|
|
|
|
36
|
my $getter = as_path($self->old_path)->getter; |
20
|
3
|
|
|
|
|
8
|
my $creator = as_path($self->new_path)->creator; |
21
|
3
|
|
|
|
|
14
|
as_path($self->new_path)->creator( |
22
|
3
|
|
|
|
|
25
|
sub { |
23
|
|
|
|
|
|
|
my ($arr, $data) = @_; |
24
|
|
|
|
|
|
|
if (is_array_ref($arr //= [])) { |
25
|
3
|
|
|
3
|
|
9
|
for my $hash (@{$getter->($data)}) { |
26
|
3
|
100
|
100
|
|
|
15
|
for my $key (sort keys %$hash) { |
27
|
2
|
|
|
|
|
4
|
push @$arr, |
|
2
|
|
|
|
|
30
|
|
28
|
2
|
|
|
|
|
11
|
{$key_name => $key, $val_name => $hash->{$key},}; |
29
|
|
|
|
|
|
|
} |
30
|
4
|
|
|
|
|
26
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
$arr; |
33
|
|
|
|
|
|
|
} |
34
|
3
|
|
|
|
|
48
|
); |
35
|
|
|
|
|
|
|
} |
36
|
3
|
|
|
|
|
18
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Catmandu::Fix::disassoc - inverse of assoc, transform a hash into an array of key value pairs |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# {fields => {subject => 'Perl', year => 2009}} |
49
|
|
|
|
|
|
|
disassoc(fields, pairs, key, val) |
50
|
|
|
|
|
|
|
# {pairs => [{key => 'year', val => 2009}, {key => 'subject', val => 'Perl'}], fields => ...} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SEE ALSO |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L<Catmandu::Fix::assoc>, L<Catmandu::Fix> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |