| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Rope::Monkey; |
|
2
|
10
|
|
|
10
|
|
3601
|
use strict; |
|
|
10
|
|
|
|
|
22
|
|
|
|
10
|
|
|
|
|
444
|
|
|
3
|
10
|
|
|
10
|
|
52
|
use warnings; |
|
|
10
|
|
|
|
|
18
|
|
|
|
10
|
|
|
|
|
665
|
|
|
4
|
10
|
|
|
10
|
|
2903
|
use Want; |
|
|
10
|
|
|
|
|
12346
|
|
|
|
10
|
|
|
|
|
854
|
|
|
5
|
|
|
|
|
|
|
my (%PRO); |
|
6
|
10
|
|
|
10
|
|
69
|
use Rope::Pro; |
|
|
10
|
|
|
|
|
17
|
|
|
|
10
|
|
|
|
|
5790
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
|
8
|
|
|
|
|
|
|
%PRO = Rope::Pro->new( |
|
9
|
|
|
|
|
|
|
monkey_patch => sub { |
|
10
|
15
|
|
|
|
|
83
|
my ($caller, $meta, $build) = @_; |
|
11
|
15
|
|
|
|
|
30
|
for my $key (keys %{$meta}) { |
|
|
15
|
|
|
|
|
77
|
|
|
12
|
61
|
100
|
|
|
|
569
|
$caller->CORE::can($key) || $PRO{keyword}($caller, $key, $PRO{monkey_patch_sub}($key)); |
|
13
|
61
|
100
|
|
|
|
138
|
if ($build) { |
|
14
|
60
|
|
|
|
|
104
|
for (qw/predicate clearer/) { |
|
15
|
120
|
100
|
|
|
|
271
|
if ($meta->{$key}->{$_}) { |
|
16
|
12
|
100
|
|
|
|
24
|
my $prep = $_ eq 'predicate' ? 'has_' : 'clear_'; |
|
17
|
12
|
|
|
|
|
46
|
my $pred = $meta->{$key}->{$_}; |
|
18
|
12
|
|
|
|
|
23
|
my $ref = ref($pred); |
|
19
|
|
|
|
|
|
|
$pred = !$ref && $pred !~ m/^\d+$/ |
|
20
|
|
|
|
|
|
|
? $pred |
|
21
|
|
|
|
|
|
|
: $ref eq 'HASH' && $pred->{name} |
|
22
|
|
|
|
|
|
|
? $pred->{name} |
|
23
|
12
|
50
|
100
|
|
|
86
|
: "$prep$key"; |
|
|
|
100
|
66
|
|
|
|
|
|
24
|
12
|
50
|
|
|
|
35
|
$caller->can($pred) || $PRO{keyword}($caller, $pred, $PRO{monkey_patch_sub}($pred)); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
} |
|
27
|
60
|
|
|
|
|
80
|
for my $handle (keys %{$meta->{$key}->{handles}}) { |
|
|
60
|
|
|
|
|
295
|
|
|
28
|
|
|
|
|
|
|
$PRO{keyword}($caller, $handle, sub { |
|
29
|
7
|
|
|
7
|
|
2540
|
my ($self) = shift; |
|
30
|
7
|
|
|
|
|
14
|
my $meth = $meta->{$key}->{handles}->{$handle}; |
|
31
|
7
|
|
|
|
|
21
|
$self->{$key}->$meth(@_); |
|
32
|
8
|
|
|
|
|
37
|
}); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
}, |
|
37
|
|
|
|
|
|
|
monkey_patch_sub => sub { |
|
38
|
60
|
|
|
|
|
1154
|
my $key = shift; |
|
39
|
|
|
|
|
|
|
return sub :lvalue { |
|
40
|
78
|
|
|
78
|
|
6988
|
my ($self) = shift; |
|
41
|
78
|
100
|
100
|
|
|
253
|
return $self->{$key}(@_) if !want(qw'LVALUE ASSIGN') && ref $self->{$key} eq 'CODE'; |
|
42
|
56
|
50
|
|
|
|
862
|
$self->{$key} = $_[0] if defined $_[0]; |
|
43
|
56
|
|
|
|
|
130
|
return $self->{$key}; |
|
44
|
60
|
|
|
|
|
439
|
}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
10
|
|
|
10
|
|
172
|
); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub import { |
|
50
|
10
|
|
|
10
|
|
77
|
my $caller = scalar(caller); |
|
51
|
|
|
|
|
|
|
$PRO{keyword}($caller, 'monkey', sub { |
|
52
|
15
|
|
|
15
|
|
67
|
my $self = shift; |
|
53
|
15
|
100
|
|
|
|
46
|
if (ref $self) { |
|
54
|
1
|
|
|
|
|
3
|
while (@_) { |
|
55
|
1
|
|
|
|
|
3
|
my ($prop, $options) = (shift @_, shift @_); |
|
56
|
1
|
|
|
|
|
4
|
$self->{$prop} = $options; |
|
57
|
1
|
|
|
|
|
4
|
$PRO{monkey_patch}($caller, { $prop => 1 }); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} else { |
|
60
|
14
|
|
|
|
|
104
|
my $meta = Rope->get_meta($caller); |
|
61
|
14
|
|
|
|
|
70
|
$PRO{monkey_patch}($caller, $meta->{properties}, 1); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
10
|
|
|
|
|
82
|
}); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Rope::Monkey - Rope Monkey Patching |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Version 0.44 |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
package Knot; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
use Rope; |
|
83
|
|
|
|
|
|
|
use Rope::Monkey; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
prototyped ( |
|
86
|
|
|
|
|
|
|
loops => 1, |
|
87
|
|
|
|
|
|
|
hitches => 10, |
|
88
|
|
|
|
|
|
|
... |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
properties { |
|
93
|
|
|
|
|
|
|
bends => { |
|
94
|
|
|
|
|
|
|
type => sub { $_[0] =~ m/^\d+$/ ? $_[0] : die "$_[0] != integer" }, |
|
95
|
|
|
|
|
|
|
value => 10, |
|
96
|
|
|
|
|
|
|
writeable => 0, |
|
97
|
|
|
|
|
|
|
configurable => 1, |
|
98
|
|
|
|
|
|
|
enumerable => 1, |
|
99
|
|
|
|
|
|
|
}, |
|
100
|
|
|
|
|
|
|
... |
|
101
|
|
|
|
|
|
|
}; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
function add_loops => sub { |
|
104
|
|
|
|
|
|
|
my ($self, $loop) = @_; |
|
105
|
|
|
|
|
|
|
$self->loops += $loop; |
|
106
|
|
|
|
|
|
|
}; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
monkey; # THIS IS IMPORTANT AND SHOULD COME AT THE END OF YOUR DEFINITION |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
... |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $k = Knot->new(); |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
say $k->loops; # 1; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$k->add_loops(5); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
say $k->loops; # 6; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$k->hitches = 15; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$k->add_loops = 5; # errors |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$k->monkey(extending => 'okay', another => { writeable => 1 }); |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 Description |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
I once had a conversation with an individual about how Autoloading was evil so here is a monkey patch version, which I personally think is as evil. I believe me and that individual have been through more than anyone else can comprehend in the modern world that we live in. Although we had very different outcomes from the process, they should understand I think this way but perhaps I am wrong to. They should find my book on the biggest book store in the world, like the rest of you. I can only speak for my truth. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
LNATION, C<< >> |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 BUGS |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
139
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
140
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SUPPORT |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
perldoc Rope |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
You can also look for information at: |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=over 4 |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * Search CPAN |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by LNATION. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This is free software, licensed under: |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; # End of Rope::Autoload |