| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | use Catmandu::Sane; | 
| 3 | 10 |  |  | 10 |  | 87517 |  | 
|  | 10 |  |  |  |  | 22 |  | 
|  | 10 |  |  |  |  | 75 |  | 
| 4 |  |  |  |  |  |  | our $VERSION = '1.2019'; | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | use Moo; | 
| 7 | 10 |  |  | 10 |  | 64 | use Catmandu::Util::Path qw(as_path); | 
|  | 10 |  |  |  |  | 20 |  | 
|  | 10 |  |  |  |  | 62 |  | 
| 8 | 10 |  |  | 10 |  | 4438 | use Clone qw(clone); | 
|  | 10 |  |  |  |  | 23 |  | 
|  | 10 |  |  |  |  | 531 |  | 
| 9 | 10 |  |  | 10 |  | 57 | use namespace::clean; | 
|  | 10 |  |  |  |  | 19 |  | 
|  | 10 |  |  |  |  | 408 |  | 
| 10 | 10 |  |  | 10 |  | 53 | use Catmandu::Fix::Has; | 
|  | 10 |  |  |  |  | 20 |  | 
|  | 10 |  |  |  |  | 59 |  | 
| 11 | 10 |  |  | 10 |  | 4509 |  | 
|  | 10 |  |  |  |  | 21 |  | 
|  | 10 |  |  |  |  | 63 |  | 
| 12 |  |  |  |  |  |  | with 'Catmandu::Fix::Builder'; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | has old_path => (fix_arg => 1); | 
| 15 |  |  |  |  |  |  | has new_path => (fix_arg => 1); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | my ($self)   = @_; | 
| 18 |  |  |  |  |  |  | my $old_path = as_path($self->old_path); | 
| 19 | 29 |  |  | 29 |  | 231 | my $new_path = as_path($self->new_path); | 
| 20 | 29 |  |  |  |  | 102 | my $getter   = $old_path->getter; | 
| 21 | 29 |  |  |  |  | 2631 | my $creator  = $new_path->creator; | 
| 22 | 29 |  |  |  |  | 460 |  | 
| 23 | 29 |  |  |  |  | 536 | sub { | 
| 24 |  |  |  |  |  |  | my $data   = $_[0]; | 
| 25 |  |  |  |  |  |  | my $values = [map {clone($_)} @{$getter->($data)}]; | 
| 26 | 55 |  |  | 55 |  | 69 | while (@$values) { | 
| 27 | 55 |  |  |  |  | 66 | $data = $creator->($data, shift @$values); | 
|  | 58 |  |  |  |  | 320 |  | 
|  | 55 |  |  |  |  | 779 |  | 
| 28 | 55 |  |  |  |  | 138 | } | 
| 29 | 58 |  |  |  |  | 878 | $data; | 
| 30 |  |  |  |  |  |  | }; | 
| 31 | 55 |  |  |  |  | 782 | } | 
| 32 | 29 |  |  |  |  | 243 |  | 
| 33 |  |  |  |  |  |  | 1; | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =pod | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | =head1 NAME | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | Catmandu::Fix::copy_field - copy the value of one field to a new field | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | # Copy the values of foo.bar into bar.foo | 
| 45 |  |  |  |  |  |  | copy_field(foo.bar, bar.foo) | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | L<Catmandu::Fix> | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =cut |