line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: A Hash Object for Perl 5 |
2
|
|
|
|
|
|
|
package Data::Object::Hash; |
3
|
|
|
|
|
|
|
|
4
|
42
|
|
|
42
|
|
26357
|
use 5.010; |
|
42
|
|
|
|
|
145
|
|
|
42
|
|
|
|
|
1946
|
|
5
|
|
|
|
|
|
|
|
6
|
42
|
|
|
42
|
|
227
|
use Carp 'confess'; |
|
42
|
|
|
|
|
62
|
|
|
42
|
|
|
|
|
2904
|
|
7
|
42
|
|
|
42
|
|
228
|
use Scalar::Util 'blessed'; |
|
42
|
|
|
|
|
60
|
|
|
42
|
|
|
|
|
2152
|
|
8
|
42
|
|
|
42
|
|
13504
|
use Data::Object 'deduce_deep', 'detract_deep'; |
|
42
|
|
|
|
|
95
|
|
|
42
|
|
|
|
|
3463
|
|
9
|
42
|
|
|
42
|
|
14098
|
use Data::Object::Class 'with'; |
|
42
|
|
|
|
|
895
|
|
|
42
|
|
|
|
|
448
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Data::Object::Role::Hash'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.20'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
56
|
|
|
56
|
0
|
64466
|
my $class = shift; |
17
|
56
|
|
|
|
|
115
|
my $data = shift; |
18
|
|
|
|
|
|
|
|
19
|
56
|
|
33
|
|
|
364
|
$class = ref($class) || $class; |
20
|
56
|
50
|
33
|
|
|
423
|
unless (blessed($data) && $data->isa($class)) { |
21
|
56
|
50
|
|
|
|
245
|
confess 'Type Instantiation Error: Not a HashRef' |
22
|
|
|
|
|
|
|
unless 'HASH' eq ref $data; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
56
|
|
|
|
|
271
|
return bless $data, $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
around 'array_slice' => sub { |
29
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
30
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
31
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
around 'aslice' => 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
|
|
|
|
|
|
|
sub data { |
47
|
2
|
|
|
2
|
0
|
10
|
goto &detract; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub detract { |
51
|
3
|
|
|
3
|
0
|
18
|
return detract_deep shift; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
around 'defined' => sub { |
55
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
56
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
57
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
around 'delete' => sub { |
61
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
62
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
63
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
around 'each' => sub { |
67
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
68
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
69
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
around 'each_key' => sub { |
73
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
74
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
75
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
around 'each_n_values' => sub { |
79
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
80
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
81
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
around 'each_value' => sub { |
85
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
86
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
87
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
88
|
|
|
|
|
|
|
}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
around 'empty' => sub { |
91
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
92
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
93
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
around 'exists' => sub { |
97
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
98
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
99
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
around 'filter_exclude' => sub { |
103
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
104
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
105
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
around 'filter_include' => 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 'hash_slice' => sub { |
121
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
122
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
123
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
124
|
|
|
|
|
|
|
}; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
around 'hslice' => sub { |
127
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
128
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
129
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
130
|
|
|
|
|
|
|
}; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
around 'invert' => 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 'keys' => sub { |
145
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
146
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
147
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
148
|
|
|
|
|
|
|
}; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub list { |
151
|
2
|
|
|
2
|
0
|
75
|
goto &values; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
around 'lookup' => sub { |
155
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
156
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
157
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
158
|
|
|
|
|
|
|
}; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
around 'merge' => sub { |
161
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
162
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
163
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
164
|
|
|
|
|
|
|
}; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
around 'pairs' => sub { |
167
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
168
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
169
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
170
|
|
|
|
|
|
|
}; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
around 'pairs_array' => sub { |
173
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
174
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
175
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
176
|
|
|
|
|
|
|
}; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
around 'reset' => sub { |
179
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
180
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
181
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
182
|
|
|
|
|
|
|
}; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
around 'reverse' => sub { |
185
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
186
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
187
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
188
|
|
|
|
|
|
|
}; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
around 'set' => sub { |
191
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
192
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
193
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
194
|
|
|
|
|
|
|
}; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
around 'values' => sub { |
197
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
198
|
|
|
|
|
|
|
my $result = deduce_deep $self->$orig(@args); |
199
|
|
|
|
|
|
|
return wantarray ? (@$result) : $result; |
200
|
|
|
|
|
|
|
}; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
1; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
__END__ |