line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Meta::Method::Signature::Compiled; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2393
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Carp; |
6
|
|
|
|
|
|
|
use HTML::Template::Pro; |
7
|
|
|
|
|
|
|
use MooseX::Method::Constant; |
8
|
|
|
|
|
|
|
use MooseX::Method::Exception; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends qw/MooseX::Meta::Method::Signature/; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:BERLE'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $validating_template = HTML::Template::Pro->new (scalarref => \<< 'EOF'); |
17
|
|
|
|
|
|
|
sub { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
eval { |
21
|
|
|
|
|
|
|
<TMPL_IF NAME="has_inline"> |
22
|
|
|
|
|
|
|
my @values = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
<TMPL_VAR NAME="body"> |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
@_ = ($self,@values); |
27
|
|
|
|
|
|
|
<TMPL_ELSE> |
28
|
|
|
|
|
|
|
@_ = ($self,<TMPL_VAR NAME="signature">->validate (@_)); |
29
|
|
|
|
|
|
|
</TMPL_IF> |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Carp::croak ("$@") |
33
|
|
|
|
|
|
|
if $@; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
goto &<TMPL_VAR NAME="coderef">; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
EOF |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _make_validating_coderef { |
40
|
|
|
|
|
|
|
my ($class,$signature,$coderef) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $params = { |
43
|
|
|
|
|
|
|
has_inline => 0, |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
if ($signature->does ('MooseX::Meta::Signature::Compiled')) { |
47
|
|
|
|
|
|
|
$params->{has_inline} = 1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$params->{body} = $signature->as_perl; |
50
|
|
|
|
|
|
|
} else { |
51
|
|
|
|
|
|
|
$params->{signature} = MooseX::Method::Constant->make ($signature); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$params->{coderef} = MooseX::Method::Constant->make ($coderef); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$validating_template->param ($params); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $new_coderef = eval $validating_template->output; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
MooseX::Method::Exception->throw ("Compilation failed: $@") |
61
|
|
|
|
|
|
|
if $@; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $new_coderef; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
MooseX::Meta::Method::Signature::Compiled - Compiled signature method metaclass |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 WARNING |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This API is unstable, it may change at any time. This should not |
79
|
|
|
|
|
|
|
affect ordinary L<MooseX::Method> usage. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SYNOPSIS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
See L<MooseX::Meta::Method::Signature> for examples on how to use |
84
|
|
|
|
|
|
|
this. Unlike the other compiled classes, it has no extra methods. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 BUGS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Most software has bugs. This module probably isn't an exception. |
89
|
|
|
|
|
|
|
If you find a bug please either email me, or add the bug to cpan-RT. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Anders Nor Berle E<lt>debolaz@gmail.comE<gt> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Copyright 2007 by Anders Nor Berle. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
100
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|