line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE |
2
|
|
|
|
|
|
|
MooseX::Declare::Context::WithOptions; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.43'; |
5
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
10674
|
use Moose::Role; |
|
24
|
|
|
|
|
37
|
|
|
24
|
|
|
|
|
134
|
|
7
|
24
|
|
|
24
|
|
81206
|
use Carp qw/croak/; |
|
24
|
|
|
|
|
36
|
|
|
24
|
|
|
|
|
1183
|
|
8
|
24
|
|
|
24
|
|
109
|
use MooseX::Types::Moose 0.20 qw/HashRef/; |
|
24
|
|
|
|
|
614
|
|
|
24
|
|
|
|
|
195
|
|
9
|
|
|
|
|
|
|
|
10
|
24
|
|
|
24
|
|
79272
|
use namespace::autoclean; |
|
24
|
|
|
|
|
39
|
|
|
24
|
|
|
|
|
202
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has options => ( |
13
|
|
|
|
|
|
|
is => 'rw', |
14
|
|
|
|
|
|
|
isa => HashRef, |
15
|
|
|
|
|
|
|
default => sub { {} }, |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub strip_options { |
20
|
63
|
|
|
63
|
0
|
118
|
my ($self) = @_; |
21
|
63
|
|
|
|
|
86
|
my %ret; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Make errors get reported from right place in source file |
24
|
63
|
|
|
|
|
207
|
local $Carp::Internal{'MooseX::Declare'} = 1; |
25
|
63
|
|
|
|
|
163
|
local $Carp::Internal{'Devel::Declare'} = 1; |
26
|
|
|
|
|
|
|
|
27
|
63
|
|
|
|
|
212
|
$self->skipspace; |
28
|
63
|
|
|
|
|
769
|
my $linestr = $self->get_linestr; |
29
|
|
|
|
|
|
|
|
30
|
63
|
|
|
|
|
640
|
while (substr($linestr, $self->offset, 1) !~ /[{;]/) { |
31
|
28
|
|
|
|
|
359
|
my $key = $self->strip_name; |
32
|
28
|
100
|
|
|
|
687
|
if (!defined $key) { |
33
|
2
|
100
|
|
|
|
155
|
croak 'expected option name' |
34
|
|
|
|
|
|
|
if keys %ret; |
35
|
1
|
|
|
|
|
4
|
return; # This is the case when { class => 'foo' } happens |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
26
|
50
|
|
|
|
151
|
croak "unknown option name '$key'" |
39
|
|
|
|
|
|
|
unless $key =~ /^(extends|with|is)$/; |
40
|
|
|
|
|
|
|
|
41
|
26
|
|
|
|
|
85
|
my $val = $self->strip_name; |
42
|
26
|
100
|
|
|
|
594
|
if (!defined $val) { |
43
|
2
|
50
|
|
|
|
26
|
if (defined($val = $self->strip_proto)) { |
44
|
2
|
|
|
|
|
150
|
$val = [split /\s*,\s*/, $val]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
0
|
|
|
|
|
0
|
croak "expected option value after $key"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
26
|
|
100
|
|
|
160
|
$ret{$key} ||= []; |
52
|
26
|
100
|
|
|
|
46
|
push @{ $ret{$key} }, ref $val ? @{ $val } : $val; |
|
26
|
|
|
|
|
121
|
|
|
2
|
|
|
|
|
7
|
|
53
|
|
|
|
|
|
|
} continue { |
54
|
26
|
|
|
|
|
86
|
$self->skipspace; |
55
|
26
|
|
|
|
|
296
|
$linestr = $self->get_linestr(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $options = { map { |
59
|
61
|
|
|
|
|
767
|
my $key = $_; |
|
23
|
|
|
|
|
48
|
|
60
|
|
|
|
|
|
|
$key eq 'is' |
61
|
5
|
|
|
|
|
23
|
? ($key => { map { ($_ => 1) } @{ $ret{$key} } }) |
|
5
|
|
|
|
|
10
|
|
62
|
23
|
100
|
|
|
|
118
|
: ($key => $ret{$key}) |
63
|
|
|
|
|
|
|
} keys %ret }; |
64
|
|
|
|
|
|
|
|
65
|
61
|
|
|
|
|
1826
|
$self->options($options); |
66
|
|
|
|
|
|
|
|
67
|
61
|
|
|
|
|
246
|
return $options; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |