line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of MooseX-CurriedDelegation |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2012 by Chris Weyl. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package MooseX::CurriedDelegation::Trait::Method::Delegation; |
11
|
|
|
|
|
|
|
BEGIN { |
12
|
1
|
|
|
1
|
|
948
|
$MooseX::CurriedDelegation::Trait::Method::Delegation::AUTHORITY = 'cpan:RSRCHBOY'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
$MooseX::CurriedDelegation::Trait::Method::Delegation::VERSION = '0.002'; |
15
|
|
|
|
|
|
|
# ABSTRACT: A trait for curried delegation methods |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
9
|
use Moose::Role; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
18
|
1
|
|
|
1
|
|
5991
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# debugging... |
21
|
|
|
|
|
|
|
#use Smart::Comments; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has curry_coderef => (is => 'ro', isa => 'Coderef', required => 1); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# _initialize_body() is largely lifted right from |
26
|
|
|
|
|
|
|
# Moose::Meta::Method::Delegation |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _initialize_body { |
29
|
2
|
|
|
2
|
|
2311
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
46
|
my $method_to_call = $self->delegate_to_method; |
32
|
|
|
|
|
|
|
# XXX |
33
|
|
|
|
|
|
|
#return $self->{body} = $method_to_call |
34
|
|
|
|
|
|
|
# if ref $method_to_call; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
21
|
my $accessor = $self->_get_delegate_accessor; |
37
|
2
|
|
|
|
|
97
|
my $handle_name = $self->name; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return $self->{body} = sub { |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
4
|
|
23542
|
my $instance = shift; |
|
|
|
|
4
|
|
|
|
|
|
|
|
4
|
|
|
|
42
|
4
|
|
|
|
|
102
|
my $proxy = $instance->$accessor(); |
43
|
4
|
|
|
|
|
236
|
my $curry_coderef = $self->curry_coderef; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
### $curry_coderef |
46
|
|
|
|
|
|
|
|
47
|
4
|
50
|
33
|
|
|
69
|
my $error |
|
|
50
|
|
|
|
|
|
48
|
|
|
|
|
|
|
= !defined $proxy ? ' is not defined' |
49
|
|
|
|
|
|
|
: ref($proxy) && !blessed($proxy) ? qq{ is not an object (got '$proxy')} |
50
|
|
|
|
|
|
|
: undef; |
51
|
|
|
|
|
|
|
|
52
|
4
|
50
|
|
|
|
12
|
if ($error) { |
53
|
0
|
|
|
|
|
0
|
$self->throw_error( |
54
|
|
|
|
|
|
|
"Cannot delegate $handle_name to $method_to_call because " |
55
|
|
|
|
|
|
|
. "the value of " |
56
|
|
|
|
|
|
|
. $self->associated_attribute->name |
57
|
|
|
|
|
|
|
. $error, |
58
|
|
|
|
|
|
|
method_name => $method_to_call, |
59
|
|
|
|
|
|
|
object => $instance |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
} |
62
|
4
|
|
|
|
|
8
|
unshift @_, @{ $self->curried_arguments }; |
|
4
|
|
|
|
|
26
|
|
63
|
4
|
|
|
|
|
38
|
unshift @_, $instance->$curry_coderef(); |
64
|
4
|
|
|
|
|
80
|
$proxy->$method_to_call(@_); |
65
|
2
|
|
|
|
|
24
|
}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
!!42; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=for :stopwords Chris Weyl |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=for :stopwords Wishlist flattr flattr'ed gittip gittip'ed |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
MooseX::CurriedDelegation::Trait::Method::Delegation - A trait for curried delegation methods |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 VERSION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This document describes version 0.002 of MooseX::CurriedDelegation::Trait::Method::Delegation - released May 19, 2014 as part of MooseX-CurriedDelegation. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is just a trait applied to the delegation method metaclass (generally |
91
|
|
|
|
|
|
|
L<Moose::Meta::Method::Delegation>). No user-serviceable parts here. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SEE ALSO |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over 4 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<MooseX::CurriedDelegation|MooseX::CurriedDelegation> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L<MooseX::CurriedDelegation> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SOURCE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The development version is on github at L<http://https://github.com/RsrchBoy/moosex-currieddelegation> |
112
|
|
|
|
|
|
|
and may be cloned from L<git://https://github.com/RsrchBoy/moosex-currieddelegation.git> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 BUGS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
117
|
|
|
|
|
|
|
https://github.com/RsrchBoy/moosex-currieddelegation/issues |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
120
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
121
|
|
|
|
|
|
|
feature. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Chris Weyl <cweyl@alumni.drew.edu> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 I'm a material boy in a material world |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=begin html |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
<a href="https://www.gittip.com/RsrchBoy/"><img src="https://raw.githubusercontent.com/gittip/www.gittip.com/master/www/assets/%25version/logo.png" /></a> |
132
|
|
|
|
|
|
|
<a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a> |
133
|
|
|
|
|
|
|
<a href="https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-currieddelegation&title=RsrchBoy's%20CPAN%20MooseX-CurriedDelegation&tags=%22RsrchBoy's%20MooseX-CurriedDelegation%20in%20the%20CPAN%22"><img src="http://api.flattr.com/button/flattr-badge-large.png" /></a> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=end html |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Please note B<I do not expect to be gittip'ed or flattr'ed for this work>, |
138
|
|
|
|
|
|
|
rather B<it is simply a very pleasant surprise>. I largely create and release |
139
|
|
|
|
|
|
|
works like this because I need them or I find it enjoyable; however, don't let |
140
|
|
|
|
|
|
|
that stop you if you feel like it ;) |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<Flattr this|https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-currieddelegation&title=RsrchBoy's%20CPAN%20MooseX-CurriedDelegation&tags=%22RsrchBoy's%20MooseX-CurriedDelegation%20in%20the%20CPAN%22>, |
143
|
|
|
|
|
|
|
L<gittip me|https://www.gittip.com/RsrchBoy/>, or indulge my |
144
|
|
|
|
|
|
|
L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If you so desire. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Chris Weyl. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This is free software, licensed under: |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |