File Coverage

blib/lib/Data/Object/Array.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 4 50.0
condition 2 6 33.3
subroutine 9 9 100.0
pod 0 4 0.0
total 37 47 78.7


line stmt bran cond sub pod time code
1             # ABSTRACT: An Array Object for Perl 5
2             package Data::Object::Array;
3              
4 87     87   52817 use 5.010;
  87         323  
  87         3928  
5              
6 87     87   494 use Carp 'confess';
  87         136  
  87         6534  
7 87     87   521 use Scalar::Util 'blessed';
  87         155  
  87         5095  
8 87     87   25128 use Data::Object 'deduce_deep', 'detract_deep';
  87         172  
  87         7400  
9 87     87   32421 use Data::Object::Class 'with';
  87         1751  
  87         892  
10              
11             with 'Data::Object::Role::Array';
12              
13             our $VERSION = '0.20'; # VERSION
14              
15             sub new {
16 163     163 0 123422 my $class = shift;
17 163         299 my $data = shift;
18              
19 163   33     922 $class = ref($class) || $class;
20 163 50 33     1074 unless (blessed($data) && $data->isa($class)) {
21 163 50       597 confess 'Type Instantiation Error: Not an ArrayRef'
22             unless 'ARRAY' eq ref $data;
23             }
24              
25 163         813 return bless $data, $class;
26             }
27              
28             around 'all' => sub {
29             my ($orig, $self, @args) = @_;
30             my $result = $self->$orig(@args);
31             return scalar deduce_deep $result;
32             };
33              
34             around 'any' => sub {
35             my ($orig, $self, @args) = @_;
36             my $result = $self->$orig(@args);
37             return scalar deduce_deep $result;
38             };
39              
40             around 'clear' => sub {
41             my ($orig, $self, @args) = @_;
42             my $result = $self->$orig(@args);
43             return scalar deduce_deep $result;
44             };
45              
46             around 'count' => sub {
47             my ($orig, $self, @args) = @_;
48             my $result = $self->$orig(@args);
49             return scalar deduce_deep $result;
50             };
51              
52             sub data {
53 2     2 0 10 goto &detract;
54             }
55              
56             sub detract {
57 3     3 0 18 return detract_deep shift;
58             }
59              
60             around 'defined' => sub {
61             my ($orig, $self, @args) = @_;
62             my $result = $self->$orig(@args);
63             return scalar deduce_deep $result;
64             };
65              
66             around 'delete' => sub {
67             my ($orig, $self, @args) = @_;
68             my $result = $self->$orig(@args);
69             return scalar deduce_deep $result;
70             };
71              
72             around 'each' => sub {
73             my ($orig, $self, @args) = @_;
74             my $result = $self->$orig(@args);
75             return scalar deduce_deep $result;
76             };
77              
78             around 'each_key' => sub {
79             my ($orig, $self, @args) = @_;
80             my $result = $self->$orig(@args);
81             return scalar deduce_deep $result;
82             };
83              
84             around 'each_n_values' => sub {
85             my ($orig, $self, @args) = @_;
86             my $result = $self->$orig(@args);
87             return scalar deduce_deep $result;
88             };
89              
90             around 'each_value' => sub {
91             my ($orig, $self, @args) = @_;
92             my $result = $self->$orig(@args);
93             return scalar deduce_deep $result;
94             };
95              
96             around 'empty' => sub {
97             my ($orig, $self, @args) = @_;
98             my $result = $self->$orig(@args);
99             return scalar deduce_deep $result;
100             };
101              
102             around 'exists' => sub {
103             my ($orig, $self, @args) = @_;
104             my $result = $self->$orig(@args);
105             return scalar deduce_deep $result;
106             };
107              
108             around 'first' => sub {
109             my ($orig, $self, @args) = @_;
110             my $result = $self->$orig(@args);
111             return scalar deduce_deep $result;
112             };
113              
114             around 'get' => sub {
115             my ($orig, $self, @args) = @_;
116             my $result = $self->$orig(@args);
117             return scalar deduce_deep $result;
118             };
119              
120             around 'grep' => sub {
121             my ($orig, $self, @args) = @_;
122             my $result = $self->$orig(@args);
123             return scalar deduce_deep $result;
124             };
125              
126             around 'hashify' => sub {
127             my ($orig, $self, @args) = @_;
128             my $result = $self->$orig(@args);
129             return scalar deduce_deep $result;
130             };
131              
132             around 'head' => sub {
133             my ($orig, $self, @args) = @_;
134             my $result = $self->$orig(@args);
135             return scalar deduce_deep $result;
136             };
137              
138             around 'iterator' => sub {
139             my ($orig, $self, @args) = @_;
140             my $result = $self->$orig(@args);
141             return scalar deduce_deep $result;
142             };
143              
144             around 'join' => sub {
145             my ($orig, $self, @args) = @_;
146             my $result = $self->$orig(@args);
147             return scalar deduce_deep $result;
148             };
149              
150             around 'keyed' => sub {
151             my ($orig, $self, @args) = @_;
152             my $result = $self->$orig(@args);
153             return scalar deduce_deep $result;
154             };
155              
156             around 'keys' => sub {
157             my ($orig, $self, @args) = @_;
158             my $result = $self->$orig(@args);
159             return scalar deduce_deep $result;
160             };
161              
162             around 'last' => sub {
163             my ($orig, $self, @args) = @_;
164             my $result = $self->$orig(@args);
165             return scalar deduce_deep $result;
166             };
167              
168             around 'length' => sub {
169             my ($orig, $self, @args) = @_;
170             my $result = $self->$orig(@args);
171             return scalar deduce_deep $result;
172             };
173              
174             sub list {
175 2     2 0 117 goto &values;
176             }
177              
178             around 'map' => sub {
179             my ($orig, $self, @args) = @_;
180             my $result = $self->$orig(@args);
181             return scalar deduce_deep $result;
182             };
183              
184             around 'max' => sub {
185             my ($orig, $self, @args) = @_;
186             my $result = $self->$orig(@args);
187             return scalar deduce_deep $result;
188             };
189              
190             around 'min' => sub {
191             my ($orig, $self, @args) = @_;
192             my $result = $self->$orig(@args);
193             return scalar deduce_deep $result;
194             };
195              
196             around 'none' => sub {
197             my ($orig, $self, @args) = @_;
198             my $result = $self->$orig(@args);
199             return scalar deduce_deep $result;
200             };
201              
202             around 'nsort' => sub {
203             my ($orig, $self, @args) = @_;
204             my $result = $self->$orig(@args);
205             return scalar deduce_deep $result;
206             };
207              
208             around 'one' => sub {
209             my ($orig, $self, @args) = @_;
210             my $result = $self->$orig(@args);
211             return scalar deduce_deep $result;
212             };
213              
214             around 'pairs' => sub {
215             my ($orig, $self, @args) = @_;
216             my $result = $self->$orig(@args);
217             return scalar deduce_deep $result;
218             };
219              
220             around 'pairs_array' => sub {
221             my ($orig, $self, @args) = @_;
222             my $result = $self->$orig(@args);
223             return scalar deduce_deep $result;
224             };
225              
226             around 'pairs_hash' => sub {
227             my ($orig, $self, @args) = @_;
228             my $result = $self->$orig(@args);
229             return scalar deduce_deep $result;
230             };
231              
232             around 'part' => sub {
233             my ($orig, $self, @args) = @_;
234             my $result = $self->$orig(@args);
235             return scalar deduce_deep $result;
236             };
237              
238             around 'pop' => sub {
239             my ($orig, $self, @args) = @_;
240             my $result = $self->$orig(@args);
241             return scalar deduce_deep $result;
242             };
243              
244             around 'push' => sub {
245             my ($orig, $self, @args) = @_;
246             my $result = $self->$orig(@args);
247             return scalar deduce_deep $result;
248             };
249              
250             around 'random' => sub {
251             my ($orig, $self, @args) = @_;
252             my $result = $self->$orig(@args);
253             return scalar deduce_deep $result;
254             };
255              
256             around 'reverse' => sub {
257             my ($orig, $self, @args) = @_;
258             my $result = $self->$orig(@args);
259             return scalar deduce_deep $result;
260             };
261              
262             around 'rnsort' => sub {
263             my ($orig, $self, @args) = @_;
264             my $result = $self->$orig(@args);
265             return scalar deduce_deep $result;
266             };
267              
268             around 'rotate' => sub {
269             my ($orig, $self, @args) = @_;
270             my $result = $self->$orig(@args);
271             return scalar deduce_deep $result;
272             };
273              
274             around 'rsort' => sub {
275             my ($orig, $self, @args) = @_;
276             my $result = $self->$orig(@args);
277             return scalar deduce_deep $result;
278             };
279              
280             around 'set' => sub {
281             my ($orig, $self, @args) = @_;
282             my $result = $self->$orig(@args);
283             return scalar deduce_deep $result;
284             };
285              
286             around 'shift' => sub {
287             my ($orig, $self, @args) = @_;
288             my $result = $self->$orig(@args);
289             return scalar deduce_deep $result;
290             };
291              
292             around 'size' => sub {
293             my ($orig, $self, @args) = @_;
294             my $result = $self->$orig(@args);
295             return scalar deduce_deep $result;
296             };
297              
298             around 'slice' => sub {
299             my ($orig, $self, @args) = @_;
300             my $result = $self->$orig(@args);
301             return scalar deduce_deep $result;
302             };
303              
304             around 'sort' => sub {
305             my ($orig, $self, @args) = @_;
306             my $result = $self->$orig(@args);
307             return scalar deduce_deep $result;
308             };
309              
310             around 'sum' => sub {
311             my ($orig, $self, @args) = @_;
312             my $result = $self->$orig(@args);
313             return scalar deduce_deep $result;
314             };
315              
316             around 'tail' => sub {
317             my ($orig, $self, @args) = @_;
318             my $result = $self->$orig(@args);
319             return scalar deduce_deep $result;
320             };
321              
322             around 'unique' => sub {
323             my ($orig, $self, @args) = @_;
324             my $result = $self->$orig(@args);
325             return scalar deduce_deep $result;
326             };
327              
328             around 'unshift' => sub {
329             my ($orig, $self, @args) = @_;
330             my $result = $self->$orig(@args);
331             return scalar deduce_deep $result;
332             };
333              
334             around 'values' => sub {
335             my ($orig, $self, @args) = @_;
336             my $result = deduce_deep $self->$orig(@args);
337             return wantarray ? (@$result) : $result;
338             };
339              
340             1;
341              
342             __END__