line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Object::Role::Proxyable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
387550
|
use 5.014; |
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
21
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
7
|
1
|
|
|
1
|
|
5
|
use routines; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
2107
|
use Moo::Role; |
|
1
|
|
|
|
|
9692
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '2.01'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# METHODS |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
313283
|
method AUTOLOAD() { |
|
4
|
|
|
|
|
8
|
|
16
|
4
|
|
|
|
|
27
|
require Carp; |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
|
|
33
|
my ($package, $method) = our $AUTOLOAD =~ m[^(.+)::(.+)$]; |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
21
|
my $build = $package->can('BUILDPROXY'); |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
15
|
my $error = qq(Can't locate object method "$method" via package "$package"); |
23
|
|
|
|
|
|
|
|
24
|
4
|
50
|
33
|
|
|
30
|
Carp::confess($error) unless $build && ref($build) eq 'CODE'; |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
11
|
my $proxy = $build->($self, $package, $method, @_); |
27
|
|
|
|
|
|
|
|
28
|
3
|
100
|
66
|
|
|
319
|
Carp::confess($error) unless $proxy && ref($proxy) eq 'CODE'; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
39
|
goto &$proxy; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
4
|
0
|
9
|
method BUILDPROXY($package, $method, @args) { |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
6
|
|
34
|
4
|
|
|
|
|
14
|
require Carp; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
19
|
my $build = $self->can('build_proxy'); |
37
|
|
|
|
|
|
|
|
38
|
4
|
100
|
|
|
|
80
|
return $build->($self, $package, $method, @args) if $build; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
120
|
Carp::confess(qq(Can't locate object method "build_proxy" via package "$package")); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
2
|
|
1777
|
method DESTROY() { |
|
2
|
|
|
|
|
5
|
|
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
6
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=encoding utf8 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Data::Object::Role::Proxyable |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 ABSTRACT |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Proxyable Role for Perl 5 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
package Example; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use Moo; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
with 'Data::Object::Role::Proxyable'; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub build_proxy { |
73
|
|
|
|
|
|
|
my ($self, $package, $method, @args) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
if ($method eq 'true') { |
76
|
|
|
|
|
|
|
return sub { |
77
|
|
|
|
|
|
|
return 1; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
if ($method eq 'false') { |
82
|
|
|
|
|
|
|
return sub { |
83
|
|
|
|
|
|
|
return 0; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return undef; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
package main; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $example = Example->new; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DESCRIPTION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This package provides a wrapper around the C routine which processes |
99
|
|
|
|
|
|
|
calls to routines which don't exist. Adding a C method to the |
100
|
|
|
|
|
|
|
consuming class acts as a hook into routine dispatching, which processes calls |
101
|
|
|
|
|
|
|
to routines which don't exist. The C routine is called as a method |
102
|
|
|
|
|
|
|
and receives C<$self>, C<$package>, C<$method>, and any arguments passed to the |
103
|
|
|
|
|
|
|
method as a list of arguments, e.g. C<@args>. The C method must |
104
|
|
|
|
|
|
|
return a routine (i.e. a callback) or the undefined value which results in a |
105
|
|
|
|
|
|
|
"method missing" error. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Al Newkirk, C |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 LICENSE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright (C) 2011-2019, Al Newkirk, et al. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the terms |
118
|
|
|
|
|
|
|
of the The Apache License, Version 2.0, as elucidated in the L<"license |
119
|
|
|
|
|
|
|
file"|https://github.com/iamalnewkirk/data-object-role-proxyable/blob/master/LICENSE>. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 PROJECT |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
L |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
L |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |