File Coverage

blib/lib/Data/Object/Hash.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 6 33.3
condition 3 9 33.3
subroutine 8 8 100.0
pod 0 4 0.0
total 33 47 70.2


line stmt bran cond sub pod time code
1             # ABSTRACT: Hash Object for Perl 5
2             package Data::Object::Hash;
3              
4 44     44   27518 use 5.010;
  44         130  
5              
6 44     44   233 use Scalar::Util 'blessed';
  44         60  
  44         3229  
7 44     44   15639 use Data::Object 'deduce_deep', 'detract_deep', 'throw';
  44         96  
  44         3643  
8 44     44   15388 use Data::Object::Class 'with';
  44         121  
  44         414  
9              
10             with 'Data::Object::Role::Hash';
11              
12             our $VERSION = '0.41'; # VERSION
13              
14             sub new {
15 74     74 0 71329 my $class = shift;
16 74 50 33     532 my $args = @_ > 1 && !(@_ % 2) ? {@_} : shift;
17 74         135 my $role = 'Data::Object::Role::Type';
18              
19 74 0 33     603 $args = $args->data if blessed($args)
      33        
20             and $args->can('does')
21             and $args->does($role);
22              
23 74 50       253 throw 'Type Instantiation Error: Not a HashRef'
24             unless 'HASH' eq ref $args;
25              
26 74         264 return bless $args, $class;
27             }
28              
29             around 'array_slice' => sub {
30             my ($orig, $self, @args) = @_;
31             my $result = $self->$orig(@args);
32             return scalar deduce_deep $result;
33             };
34              
35             around 'aslice' => sub {
36             my ($orig, $self, @args) = @_;
37             my $result = $self->$orig(@args);
38             return scalar deduce_deep $result;
39             };
40              
41             around 'clear' => sub {
42             my ($orig, $self, @args) = @_;
43             my $result = $self->$orig(@args);
44             return scalar deduce_deep $result;
45             };
46              
47             sub data {
48 2     2 0 12 goto &detract;
49             }
50              
51             sub detract {
52 3     3 0 21 return detract_deep shift;
53             }
54              
55             around 'defined' => sub {
56             my ($orig, $self, @args) = @_;
57             my $result = $self->$orig(@args);
58             return scalar deduce_deep $result;
59             };
60              
61             around 'delete' => sub {
62             my ($orig, $self, @args) = @_;
63             my $result = $self->$orig(@args);
64             return scalar deduce_deep $result;
65             };
66              
67             around 'each' => sub {
68             my ($orig, $self, @args) = @_;
69             my $result = $self->$orig(@args);
70             return scalar deduce_deep $result;
71             };
72              
73             around 'each_key' => sub {
74             my ($orig, $self, @args) = @_;
75             my $result = $self->$orig(@args);
76             return scalar deduce_deep $result;
77             };
78              
79             around 'each_n_values' => sub {
80             my ($orig, $self, @args) = @_;
81             my $result = $self->$orig(@args);
82             return scalar deduce_deep $result;
83             };
84              
85             around 'each_value' => sub {
86             my ($orig, $self, @args) = @_;
87             my $result = $self->$orig(@args);
88             return scalar deduce_deep $result;
89             };
90              
91             around 'empty' => sub {
92             my ($orig, $self, @args) = @_;
93             my $result = $self->$orig(@args);
94             return scalar deduce_deep $result;
95             };
96              
97             around 'exists' => sub {
98             my ($orig, $self, @args) = @_;
99             my $result = $self->$orig(@args);
100             return scalar deduce_deep $result;
101             };
102              
103             around 'filter_exclude' => sub {
104             my ($orig, $self, @args) = @_;
105             my $result = $self->$orig(@args);
106             return scalar deduce_deep $result;
107             };
108              
109             around 'filter_include' => sub {
110             my ($orig, $self, @args) = @_;
111             my $result = $self->$orig(@args);
112             return scalar deduce_deep $result;
113             };
114              
115             around 'fold' => sub {
116             my ($orig, $self, @args) = @_;
117             my $result = $self->$orig(@args);
118             return scalar deduce_deep $result;
119             };
120              
121             around 'get' => sub {
122             my ($orig, $self, @args) = @_;
123             my $result = $self->$orig(@args);
124             return scalar deduce_deep $result;
125             };
126              
127             around 'hash_slice' => sub {
128             my ($orig, $self, @args) = @_;
129             my $result = $self->$orig(@args);
130             return scalar deduce_deep $result;
131             };
132              
133             around 'hslice' => sub {
134             my ($orig, $self, @args) = @_;
135             my $result = $self->$orig(@args);
136             return scalar deduce_deep $result;
137             };
138              
139             around 'invert' => sub {
140             my ($orig, $self, @args) = @_;
141             my $result = $self->$orig(@args);
142             return scalar deduce_deep $result;
143             };
144              
145             around 'iterator' => sub {
146             my ($orig, $self, @args) = @_;
147             my $result = $self->$orig(@args);
148             return scalar deduce_deep $result;
149             };
150              
151             around 'keys' => sub {
152             my ($orig, $self, @args) = @_;
153             my $result = $self->$orig(@args);
154             return scalar deduce_deep $result;
155             };
156              
157             sub list {
158 2     2 0 71 goto &values;
159             }
160              
161             around 'lookup' => sub {
162             my ($orig, $self, @args) = @_;
163             my $result = $self->$orig(@args);
164             return scalar deduce_deep $result;
165             };
166              
167             around 'merge' => sub {
168             my ($orig, $self, @args) = @_;
169             my $result = $self->$orig(@args);
170             return scalar deduce_deep $result;
171             };
172              
173             around 'pairs' => sub {
174             my ($orig, $self, @args) = @_;
175             my $result = $self->$orig(@args);
176             return scalar deduce_deep $result;
177             };
178              
179             around 'pairs_array' => sub {
180             my ($orig, $self, @args) = @_;
181             my $result = $self->$orig(@args);
182             return scalar deduce_deep $result;
183             };
184              
185             around 'reset' => sub {
186             my ($orig, $self, @args) = @_;
187             my $result = $self->$orig(@args);
188             return scalar deduce_deep $result;
189             };
190              
191             around 'reverse' => sub {
192             my ($orig, $self, @args) = @_;
193             my $result = $self->$orig(@args);
194             return scalar deduce_deep $result;
195             };
196              
197             around 'set' => sub {
198             my ($orig, $self, @args) = @_;
199             my $result = $self->$orig(@args);
200             return scalar deduce_deep $result;
201             };
202              
203             around 'unfold' => sub {
204             my ($orig, $self, @args) = @_;
205             my $result = $self->$orig(@args);
206             return scalar deduce_deep $result;
207             };
208              
209             around 'values' => sub {
210             my ($orig, $self, @args) = @_;
211             my $result = deduce_deep $self->$orig(@args);
212             return wantarray ? (@$result) : $result;
213             };
214              
215             1;
216              
217             __END__