line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::MultiObject::Meta::Method::MultiDelegation; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
21
|
$MooseX::MultiObject::Meta::Method::MultiDelegation::VERSION = '0.01'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: method that delegates to a set of object |
6
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
21
|
|
8
|
1
|
|
|
1
|
|
3
|
use true; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
484
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
41
|
use Carp qw(confess); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
3
|
use parent 'Moose::Meta::Method', 'Class::MOP::Method::Generated'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# i hate class mop |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
2
|
|
|
2
|
0
|
4
|
my $class = shift; |
18
|
2
|
|
|
|
|
7
|
my %options = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
confess 'You must supply an object_getter method name' |
21
|
2
|
50
|
|
|
|
5
|
unless exists $options{object_getter}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
confess 'You must supply a delegate_to method or coderef' |
24
|
2
|
50
|
|
|
|
4
|
unless exists $options{delegate_to}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
exists $options{curried_arguments} |
27
|
2
|
50
|
|
|
|
5
|
|| ( $options{curried_arguments} = [] ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
( $options{curried_arguments} && |
30
|
2
|
50
|
33
|
|
|
10
|
( 'ARRAY' eq ref $options{curried_arguments} ) ) |
31
|
|
|
|
|
|
|
|| confess 'You must supply a curried_arguments which is an ARRAY reference'; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
5
|
my $self = $class->_new( \%options ); |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
5
|
$self->_initialize_body; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
5
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _new { |
41
|
2
|
|
|
2
|
|
3
|
my $class = shift; |
42
|
2
|
50
|
|
|
|
5
|
my $options = @_ == 1 ? $_[0] : {@_}; |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
4
|
return bless $options, $class; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
2
|
0
|
81
|
sub object_getter { $_[0]->{object_getter} } |
48
|
2
|
|
|
2
|
0
|
4
|
sub curried_arguments { $_[0]->{curried_arguments} } |
49
|
2
|
|
|
2
|
0
|
3
|
sub delegate_to { $_[0]->{delegate_to} } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _initialize_body { |
52
|
2
|
|
|
2
|
|
3
|
my $meta = shift; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
3
|
my $object_getter = $meta->object_getter; |
55
|
2
|
|
|
|
|
3
|
my @extra_args = @{$meta->curried_arguments}; |
|
2
|
|
|
|
|
4
|
|
56
|
2
|
|
|
|
|
4
|
my $delegate_to = $meta->delegate_to; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$meta->{body} = sub { |
59
|
2
|
|
|
2
|
|
1673
|
my $self = shift; |
|
|
|
|
2
|
|
|
|
|
|
|
|
2
|
|
|
|
60
|
2
|
|
|
|
|
3
|
unshift @_, @extra_args; |
61
|
2
|
|
|
|
|
7
|
my @objects = $self->$object_getter; |
62
|
2
|
|
|
|
|
15
|
return map { scalar $_->$delegate_to(@_) } @objects; |
|
2
|
|
|
|
|
34
|
|
63
|
2
|
|
|
|
|
9
|
}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
MooseX::MultiObject::Meta::Method::MultiDelegation - method that delegates to a set of object |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 0.01 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Jonathan Rockway <jrockway@cpan.org> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Jonathan Rockway. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
86
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|