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