line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::MethodProxyArgs; |
2
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=encoding utf8 |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
MooX::MethodProxyArgs - Invoke code to populate static arguments. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Foo; |
13
|
|
|
|
|
|
|
use Moo; |
14
|
|
|
|
|
|
|
with 'MooX::MethodProxyArgs'; |
15
|
|
|
|
|
|
|
has bar => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package main; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub divide { |
22
|
|
|
|
|
|
|
my ($class, $number, $divisor) = @_; |
23
|
|
|
|
|
|
|
return $number / $divisor; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $foo = Foo->new( bar => ['$proxy', 'main', 'divide', 10, 2 ] ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
print $foo->bar(); # 5 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This module munges the class's input arguments by replacing any |
33
|
|
|
|
|
|
|
method proxy values found with the result of calling the methods. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This is done using L. See that module for more |
36
|
|
|
|
|
|
|
information on how method proxies work. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
8240
|
use Data::MethodProxy; |
|
1
|
|
|
|
|
715
|
|
|
1
|
|
|
|
|
25
|
|
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
6
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
43
|
1
|
|
|
1
|
|
299
|
use strictures 2; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
44
|
|
44
|
1
|
|
|
1
|
|
598
|
use namespace::clean; |
|
1
|
|
|
|
|
9242
|
|
|
1
|
|
|
|
|
6
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
with 'MooX::BuildArgsHooks'; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $mproxy = Data::MethodProxy->new(); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
around TRANSFORM_BUILDARGS => sub{ |
51
|
|
|
|
|
|
|
my ($orig, $class, $args) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$args = $class->TRANSFORM_METHOD_PROXY_ARGS_BUILDARGS( $args ); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return $class->$orig( $args ); |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub TRANSFORM_METHOD_PROXY_ARGS_BUILDARGS { |
59
|
1
|
|
|
1
|
0
|
3
|
my ($class, $args) = @_; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
5
|
return $mproxy->render( $args ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |