line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Deferrable; |
2
|
|
|
|
|
|
|
|
3
|
96
|
|
|
96
|
|
1704
|
use 5.018; |
|
96
|
|
|
|
|
349
|
|
4
|
|
|
|
|
|
|
|
5
|
96
|
|
|
96
|
|
546
|
use strict; |
|
96
|
|
|
|
|
217
|
|
|
96
|
|
|
|
|
2011
|
|
6
|
96
|
|
|
96
|
|
513
|
use warnings; |
|
96
|
|
|
|
|
202
|
|
|
96
|
|
|
|
|
2497
|
|
7
|
|
|
|
|
|
|
|
8
|
96
|
|
|
96
|
|
497
|
use Venus::Role 'fault'; |
|
96
|
|
|
|
|
248
|
|
|
96
|
|
|
|
|
585
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# METHODS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub defer { |
13
|
55
|
|
|
55
|
1
|
286
|
my ($self, $name, @args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
55
|
100
|
|
1
|
|
151
|
return sub {$self} if !$name; |
|
1
|
|
|
|
|
14
|
|
16
|
|
|
|
|
|
|
|
17
|
54
|
50
|
|
|
|
305
|
my $code = $self->can($name) |
18
|
0
|
|
|
|
|
0
|
or fault "Unable to defer $name: can't find $name in @{[ref $self]}"; |
19
|
|
|
|
|
|
|
|
20
|
54
|
|
|
25
|
|
586
|
return sub {@_ = ($self, @args, @_); goto $code}; |
|
25
|
|
|
|
|
5107
|
|
|
25
|
|
|
|
|
196
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# EXPORTS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub EXPORT { |
26
|
100
|
|
|
100
|
0
|
399
|
['defer'] |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Venus::Role::Deferrable - Deferrable Role |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 ABSTRACT |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Deferrable Role for Perl 5 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
package Example; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use Venus::Class; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
with 'Venus::Role::Deferrable'; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub test { |
54
|
|
|
|
|
|
|
my ($self, @args) = @_; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return $self->okay(@args); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub okay { |
60
|
|
|
|
|
|
|
my ($self, @args) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return [@args]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package main; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $example = Example->new; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# my $code = $example->defer('test'); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# sub {...} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# $code->(); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# [...] |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This package provides a mechanism for returning callbacks (i.e. closures) that |
82
|
|
|
|
|
|
|
dispatches method calls. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 METHODS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This package provides the following methods: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 defer |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
defer(string $method, any @args) (coderef) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The defer method returns the named method as a callback (i.e. closure) which |
97
|
|
|
|
|
|
|
dispatches to the method call specified. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
I> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over 4 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item defer example 1 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# given: synopsis |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
package main; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
$example = Example->new; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# bless({}, 'Example') |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# my $result = $example->defer('test', 1..4); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# $result->(); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# [1..4] |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=back |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over 4 |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item defer example 2 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# given: synopsis |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
package main; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
$example = Example->new; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# bless({}, 'Example') |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# my $result = $example->defer('test', 1..4); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# $result->(1..4); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# [1..4, 1..4] |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over 4 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item defer example 3 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# given: synopsis |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
package main; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$example = Example->new; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# bless({}, 'Example') |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# my $result = $example->defer; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# $result->(); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# bless({}, 'Example') |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHORS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Awncorp, C |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 LICENSE |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Copyright (C) 2000, Awncorp, C. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
174
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |