line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::MethodProxyArgs; |
2
|
1
|
|
|
1
|
|
9398
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
3
|
1
|
|
|
1
|
|
6
|
use strictures 2; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
44
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
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
|
|
703
|
use Data::MethodProxy; |
|
1
|
|
|
|
|
761
|
|
|
1
|
|
|
|
|
30
|
|
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
7
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
43
|
1
|
|
|
1
|
|
848
|
use namespace::clean; |
|
1
|
|
|
|
|
10808
|
|
|
1
|
|
|
|
|
8
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
with 'MooX::BuildArgsHooks'; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $mproxy = Data::MethodProxy->new(); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
around TRANSFORM_BUILDARGS => sub{ |
50
|
|
|
|
|
|
|
my ($orig, $class, $args) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$args = $class->TRANSFORM_METHOD_PROXY_ARGS_BUILDARGS( $args ); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return $class->$orig( $args ); |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub TRANSFORM_METHOD_PROXY_ARGS_BUILDARGS { |
58
|
1
|
|
|
1
|
0
|
3
|
my ($class, $args) = @_; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
6
|
return $mproxy->render( $args ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |