line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::MethodProxyArgs; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$MooX::MethodProxyArgs::VERSION = '0.06'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
MooX::MethodProxyArgs - Invoke code to populate static arguments. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Foo; |
12
|
|
|
|
|
|
|
use Moo; |
13
|
|
|
|
|
|
|
with 'MooX::MethodProxyArgs'; |
14
|
|
|
|
|
|
|
has bar => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package main; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub divide { |
21
|
|
|
|
|
|
|
my ($class, $number, $divisor) = @_; |
22
|
|
|
|
|
|
|
return $number / $divisor; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $foo = Foo->new( bar => ['$proxy', 'main', 'divide', 10, 2 ] ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
print $foo->bar(); # 5 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This module munges the class's input arguments by replacing any |
32
|
|
|
|
|
|
|
method proxy values found with the result of calling the methods. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This is done using L. See that module for more |
35
|
|
|
|
|
|
|
information on how method proxies work. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
1
|
|
10809
|
use Data::MethodProxy; |
|
1
|
|
|
|
|
799
|
|
|
1
|
|
|
|
|
31
|
|
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
6
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
42
|
1
|
|
|
1
|
|
814
|
use strictures 2; |
|
1
|
|
|
|
|
1609
|
|
|
1
|
|
|
|
|
39
|
|
43
|
1
|
|
|
1
|
|
720
|
use namespace::clean; |
|
1
|
|
|
|
|
11318
|
|
|
1
|
|
|
|
|
7
|
|
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
|
|
|
|
|
|
|
return $class->$orig( |
53
|
|
|
|
|
|
|
$mproxy->render( $args ), |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
__END__ |