| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooseX::MultiInitArg::Trait; |
|
2
|
2
|
|
|
2
|
|
134219
|
use Moose::Role; |
|
|
2
|
|
|
|
|
13403
|
|
|
|
2
|
|
|
|
|
17
|
|
|
3
|
2
|
|
|
2
|
|
13482
|
use Carp qw(confess); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
671
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has init_args => ( |
|
6
|
|
|
|
|
|
|
is => 'ro', |
|
7
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
8
|
|
|
|
|
|
|
predicate => 'has_init_args', |
|
9
|
|
|
|
|
|
|
); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
around initialize_instance_slot => sub { |
|
12
|
|
|
|
|
|
|
my $original = shift; |
|
13
|
|
|
|
|
|
|
my ($self, $meta_instance, $instance, $params) = @_; |
|
14
|
|
|
|
|
|
|
if ($self->has_init_args) |
|
15
|
|
|
|
|
|
|
{ |
|
16
|
|
|
|
|
|
|
if(my @supplied = grep { exists $params->{$_} } @{ $self->init_args }) |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
|
|
|
|
|
|
if ($self->has_init_arg and exists $params->{ $self->init_arg }) |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
|
|
|
|
|
|
push(@supplied, $self->init_arg); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if (@supplied > 1) |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
|
|
|
|
|
|
confess 'Conflicting init_args: (' . join(', ', @supplied) . ')'; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$self->_set_initial_slot_value( |
|
29
|
|
|
|
|
|
|
$meta_instance, |
|
30
|
|
|
|
|
|
|
$instance, |
|
31
|
|
|
|
|
|
|
$params->{$supplied[0]}, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
$original->(@_); |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
2
|
|
|
2
|
|
93
|
no Moose::Role; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
11
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
MooseX::MultiInitArg::Trait - A composable role to add multiple init arguments |
|
50
|
|
|
|
|
|
|
to your attributes. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This is a composable trait which you can add to an attribute so that you can |
|
55
|
|
|
|
|
|
|
specify a list of aliases for your attribute to be recognized as constructor |
|
56
|
|
|
|
|
|
|
arguments. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 AUTHOR |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Paul Driver, C<< <frodwith at cpan.org> >> |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Copyright 2007-2008 by Paul Driver. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
67
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|