File Coverage

blib/lib/Data/Zipper/MOP.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Data::Zipper::MOP;
2             BEGIN {
3 2     2   23530 $Data::Zipper::MOP::VERSION = '0.02';
4             }
5             # ABSTRACT: A zipper for MOP based objects
6              
7 2     2   17 use warnings FATAL => 'all';
  2         5  
  2         79  
8 2     2   1016 use Moose;
  2         547183  
  2         17  
9 2     2   23509 use namespace::autoclean;
  2         4963  
  2         15  
10              
11 2     2   2630 use MooseX::Types::Moose qw( Object Str ArrayRef );
  2         175764  
  2         25  
12 2     2   15883 use MooseX::Types::Structured qw( Tuple );
  2         1103127  
  2         19  
13              
14             with 'Data::Zipper::API' => { type => Tuple[ Str, Object ] };
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 5     5 1 15 my ($self, $value, $path) = @_;
26 5         15 my ($key, $object) = @$path;
27 5         30 $object->meta->clone_object(
28             $object,
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::MOP - A zipper for MOP based objects
45              
46             =head1 METHODS
47              
48             =head2 traverse
49              
50             Traverse into the object under focus, by moving into the value of an attribute
51             with a given name. Currently assumes the reader is the same as the name.
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