File Coverage

blib/lib/Data/Seek/Data.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition 2 4 50.0
subroutine 7 7 100.0
pod 2 2 100.0
total 32 34 94.1


line stmt bran cond sub pod time code
1             # ABSTRACT: Data::Seek Data Structure Container
2             package Data::Seek::Data;
3              
4 4     4   839 use 5.10.0;
  4         11  
  4         164  
5 4     4   19 use strict;
  4         7  
  4         114  
6 4     4   18 use warnings;
  4         7  
  4         97  
7              
8 4     4   2492 use Mo;
  4         1727  
  4         22  
9              
10 4     4   3571 use Hash::Flatten ();
  4         9923  
  4         545  
11              
12             our $VERSION = '0.05'; # VERSION
13              
14             has 'object';
15              
16             sub decode {
17 1     1 1 2 my $self = shift;
18 1   50     4 my $object = $self->object // {};
19 1         10 return Hash::Flatten::unflatten $object;
20             }
21              
22             sub encode {
23 42     42 1 757 my $self = shift;
24 42   50     129 my $object = $self->object // {};
25 42         341 return Hash::Flatten::flatten $object;
26             }
27              
28             1;
29              
30             __END__
31              
32             =pod
33              
34             =encoding UTF-8
35              
36             =head1 NAME
37              
38             Data::Seek::Data - Data::Seek Data Structure Container
39              
40             =head1 VERSION
41              
42             version 0.05
43              
44             =head1 SYNOPSIS
45              
46             use Data::Seek::Data;
47              
48             =head1 DESCRIPTION
49              
50             Data::Seek::Data is a class within L<Data::Seek> which acts as a container for a
51             data structure which is intended to be provided to L<Data::Seek::Search>.
52              
53             =head1 ATTRIBUTES
54              
55             =head2 object
56              
57             $data->object;
58             $data->object($hash);
59              
60             Contains the data structure to be introspected, encoded and/or decoded, and must
61             be a hash reference.
62              
63             =head1 METHODS
64              
65             =head2 decode
66              
67             my $hash = $data->decode;
68              
69             Uses L<Hash::Flatten> to unflatten/unfold the data structure returning a hash
70             reference.
71              
72             =head2 encode
73              
74             my $hash = $data->encode;
75              
76             Uses L<Hash::Flatten> to flatten/fold the data structure returning a hash
77             reference.
78              
79             =encoding utf8
80              
81             =head1 AUTHOR
82              
83             Al Newkirk <anewkirk@ana.io>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is copyright (c) 2014 by Al Newkirk.
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =cut