line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::PDL::Role::Proxy; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: treat a container of piddles as if it were a piddle |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
738124
|
use 5.010; |
|
2
|
|
|
|
|
22
|
|
6
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
37
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
111
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
1101
|
use Types::Standard -types; |
|
2
|
|
|
|
|
147571
|
|
|
2
|
|
|
|
|
22
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
9464
|
use PDL::Primitive (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
39
|
|
14
|
2
|
|
|
2
|
|
595
|
use Hash::Wrap; |
|
2
|
|
|
|
|
2644
|
|
|
2
|
|
|
|
|
14
|
|
15
|
2
|
|
|
2
|
|
1619
|
use Scalar::Util (); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
33
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
910
|
use Moo::Role; |
|
2
|
|
|
|
|
16769
|
|
|
2
|
|
|
|
|
13
|
|
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
1866
|
use namespace::clean; |
|
2
|
|
|
|
|
22128
|
|
|
2
|
|
|
|
|
13
|
|
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
2220
|
use MooX::TaggedAttributes -tags => [qw( piddle )]; |
|
2
|
|
|
|
|
44539
|
|
|
2
|
|
|
|
|
10
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# requires 'clone_with_piddles'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has _piddles => ( |
35
|
|
|
|
|
|
|
is => 'lazy', |
36
|
|
|
|
|
|
|
isa => ArrayRef [Str], |
37
|
|
|
|
|
|
|
init_arg => undef, |
38
|
|
|
|
|
|
|
builder => sub { |
39
|
32
|
|
|
32
|
|
313
|
my $self = shift; |
40
|
32
|
|
|
|
|
53
|
[ keys %{ $self->_tags->{piddle} } ]; |
|
32
|
|
|
|
|
93
|
|
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has _set_attr_subs => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => HashRef, |
47
|
|
|
|
|
|
|
init_arg => undef, |
48
|
|
|
|
|
|
|
default => sub { {} }, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has _piddle_op_inplace => ( |
53
|
|
|
|
|
|
|
is => 'rwp', |
54
|
|
|
|
|
|
|
init_arg => undef, |
55
|
|
|
|
|
|
|
clearer => 1, |
56
|
|
|
|
|
|
|
default => 0 |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _apply_to_tagged_attrs { |
76
|
20
|
|
|
20
|
|
46
|
my ( $self, $action ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
20
|
|
|
|
|
54
|
my $inplace = $self->_piddle_op_inplace; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my %attr = map { |
81
|
40
|
|
|
|
|
1646
|
my $field = $_; |
82
|
40
|
|
|
|
|
162
|
$field => $action->( $self->$field, $inplace ); |
83
|
20
|
|
|
|
|
35
|
} @{ $self->_piddles }; |
|
20
|
|
|
|
|
428
|
|
84
|
|
|
|
|
|
|
|
85
|
20
|
100
|
|
|
|
349
|
if ( $self->_piddle_op_inplace ) { |
86
|
4
|
|
|
|
|
90
|
$self->_clear_piddle_op_inplace; |
87
|
4
|
|
|
|
|
37
|
$self->_set_attr( %attr ); |
88
|
4
|
|
|
|
|
29
|
return $self; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
16
|
|
|
|
|
77
|
return $self->clone_with_piddles( %attr ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub inplace { |
104
|
4
|
|
|
4
|
1
|
276
|
my $self = shift; |
105
|
4
|
|
|
|
|
60
|
$self->_set__piddle_op_inplace( 1 ); |
106
|
4
|
|
|
|
|
39
|
return $self; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
0
|
1
|
0
|
sub is_inplace { !! $_[0]->__piddle_op_inplace } |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub copy { |
131
|
4
|
|
|
4
|
1
|
116
|
my $self = shift; |
132
|
8
|
|
|
|
|
342
|
return $self->clone_with_piddles( map { $_ => $self->$_->copy } |
133
|
4
|
|
|
|
|
9
|
@{ $self->_piddles } ); |
|
4
|
|
|
|
|
83
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub sever { |
145
|
4
|
|
|
4
|
1
|
12411
|
my $self = shift; |
146
|
4
|
|
|
|
|
8
|
$self->$_->sever for @{ $self->_piddles }; |
|
4
|
|
|
|
|
92
|
|
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub index { |
158
|
12
|
|
|
12
|
1
|
738
|
my ( $self, $index ) = @_; |
159
|
12
|
|
|
24
|
|
67
|
return $self->_apply_to_tagged_attrs( sub { $_[0]->index( $index ) } ); |
|
24
|
|
|
|
|
227
|
|
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# is there a use for this? |
163
|
|
|
|
|
|
|
# sub which { |
164
|
|
|
|
|
|
|
# my ( $self, $which ) = @_; |
165
|
|
|
|
|
|
|
# return PDL::Primitive::which( |
166
|
|
|
|
|
|
|
# 'CODE' eq ref $which |
167
|
|
|
|
|
|
|
# ? do { local $_ = $self; $which->() } |
168
|
|
|
|
|
|
|
# : $which |
169
|
|
|
|
|
|
|
# ); |
170
|
|
|
|
|
|
|
# } |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub at { |
183
|
4
|
|
|
4
|
1
|
166
|
my ( $self, @idx ) = @_; |
184
|
4
|
|
|
|
|
9
|
wrap_hash( { map { $_ => $self->$_->at( @idx ) } @{ $self->_piddles } } ); |
|
8
|
|
|
|
|
337
|
|
|
4
|
|
|
|
|
74
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub where { |
196
|
8
|
|
|
8
|
1
|
622
|
my ( $self, $where ) = @_; |
197
|
|
|
|
|
|
|
|
198
|
8
|
|
|
16
|
|
49
|
return $self->_apply_to_tagged_attrs( sub { $_[0]->where( $where ) } ); |
|
16
|
|
|
|
|
71
|
|
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub _set_attr { |
213
|
24
|
|
|
24
|
|
1628
|
my ( $self, %attr ) = @_; |
214
|
24
|
|
|
|
|
67
|
my $subs = $self->_set_attr_subs; |
215
|
|
|
|
|
|
|
|
216
|
24
|
|
|
|
|
70
|
for my $key ( keys %attr ) { |
217
|
48
|
|
|
|
|
85
|
my $sub = $subs->{$key}; |
218
|
|
|
|
|
|
|
|
219
|
48
|
50
|
|
|
|
110
|
if ( !defined $sub ) { |
220
|
48
|
|
33
|
|
|
274
|
Scalar::Util::weaken( $subs->{$key} = $self->can( "_set_${key}" ) |
221
|
|
|
|
|
|
|
// $self->can( $key ) ); |
222
|
48
|
|
|
|
|
85
|
$sub = $subs->{$key}; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
48
|
|
|
|
|
241
|
$sub->( $self, $attr{$key} ); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
24
|
|
|
|
|
155
|
return $self; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
1; |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
# |
235
|
|
|
|
|
|
|
# This file is part of MooX-PDL-Role-Proxy |
236
|
|
|
|
|
|
|
# |
237
|
|
|
|
|
|
|
# This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. |
238
|
|
|
|
|
|
|
# |
239
|
|
|
|
|
|
|
# This is free software, licensed under: |
240
|
|
|
|
|
|
|
# |
241
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
242
|
|
|
|
|
|
|
# |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
__END__ |