File Coverage

blib/lib/Data/Zipper/Hash.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 28 28 100.0


line stmt bran cond sub pod time code
1             package Data::Zipper::Hash;
2             BEGIN {
3 2     2   2652 $Data::Zipper::Hash::VERSION = '0.02';
4             }
5             # ABSTRACT: A zipper for hash references
6              
7 2     2   20 use warnings FATAL => 'all';
  2         6  
  2         130  
8 2     2   1067 use Moose;
  2         414538  
  2         20  
9 2     2   16050 use namespace::autoclean;
  2         1476  
  2         20  
10              
11 2     2   1031 use MooseX::Types::Moose qw( Str HashRef );
  2         57961  
  2         27  
12 2     2   13020 use MooseX::Types::Structured qw( Tuple );
  2         511708  
  2         20  
13              
14             with 'Data::Zipper::API' => { type => Tuple[ Str, HashRef ] };
15              
16             sub traverse {
17             my ($self, $path) = @_;
18             return (
19             $self->focus->{$path},
20             [ $path, $self->focus ],
21             );
22             }
23              
24             sub reconstruct {
25 3     3 1 8 my ($self, $value, $path) = @_;
26 3         10 my ($key, $object) = @$path;
27             return {
28 3         5 %{ $object },
  3         45  
29             $key => $value
30             };
31             }
32              
33             __PACKAGE__->meta->make_immutable;
34             1;
35              
36              
37             __END__
38             =pod
39              
40             =encoding utf-8
41              
42             =head1 NAME
43              
44             Data::Zipper::Hash - A zipper for hash references
45              
46             =head1 METHODS
47              
48             =head2 traverse
49              
50             Traverse into the currently focused hash reference by moving into
51             the value of L<$key>.
52              
53             =head2 reconstruct
54              
55             (internal)
56              
57             =head1 AUTHOR
58              
59             Oliver Charles
60              
61             =head1 COPYRIGHT AND LICENSE
62              
63             This software is copyright (c) 2011 by Oliver Charles <oliver.g.charles@googlemail.com>.
64              
65             This is free software; you can redistribute it and/or modify it under
66             the same terms as the Perl 5 programming language system itself.
67              
68             =cut
69