line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Declare::Context::WithOptions; |
2
|
|
|
|
|
|
|
$MooseX::Declare::Context::WithOptions::VERSION = '0.39'; |
3
|
24
|
|
|
24
|
|
21935
|
use Moose::Role; |
|
24
|
|
|
|
|
57
|
|
|
24
|
|
|
|
|
207
|
|
4
|
24
|
|
|
24
|
|
163278
|
use Carp qw/croak/; |
|
24
|
|
|
|
|
65
|
|
|
24
|
|
|
|
|
1673
|
|
5
|
24
|
|
|
24
|
|
161
|
use MooseX::Types::Moose 0.20 qw/HashRef/; |
|
24
|
|
|
|
|
874
|
|
|
24
|
|
|
|
|
265
|
|
6
|
|
|
|
|
|
|
|
7
|
24
|
|
|
24
|
|
142641
|
use namespace::clean -except => 'meta'; |
|
24
|
|
|
|
|
65
|
|
|
24
|
|
|
|
|
298
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has options => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
isa => HashRef, |
12
|
|
|
|
|
|
|
default => sub { {} }, |
13
|
|
|
|
|
|
|
lazy => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub strip_options { |
17
|
63
|
|
|
63
|
0
|
169
|
my ($self) = @_; |
18
|
63
|
|
|
|
|
139
|
my %ret; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Make errors get reported from right place in source file |
21
|
63
|
|
|
|
|
293
|
local $Carp::Internal{'MooseX::Declare'} = 1; |
22
|
63
|
|
|
|
|
217
|
local $Carp::Internal{'Devel::Declare'} = 1; |
23
|
|
|
|
|
|
|
|
24
|
63
|
|
|
|
|
318
|
$self->skipspace; |
25
|
63
|
|
|
|
|
1390
|
my $linestr = $self->get_linestr; |
26
|
|
|
|
|
|
|
|
27
|
63
|
|
|
|
|
1145
|
while (substr($linestr, $self->offset, 1) !~ /[{;]/) { |
28
|
28
|
|
|
|
|
554
|
my $key = $self->strip_name; |
29
|
28
|
100
|
|
|
|
1260
|
if (!defined $key) { |
30
|
2
|
100
|
|
|
|
223
|
croak 'expected option name' |
31
|
|
|
|
|
|
|
if keys %ret; |
32
|
1
|
|
|
|
|
7
|
return; # This is the case when { class => 'foo' } happens |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
26
|
50
|
|
|
|
188
|
croak "unknown option name '$key'" |
36
|
|
|
|
|
|
|
unless $key =~ /^(extends|with|is)$/; |
37
|
|
|
|
|
|
|
|
38
|
26
|
|
|
|
|
98
|
my $val = $self->strip_name; |
39
|
26
|
100
|
|
|
|
1073
|
if (!defined $val) { |
40
|
2
|
50
|
|
|
|
27
|
if (defined($val = $self->strip_proto)) { |
41
|
2
|
|
|
|
|
191
|
$val = [split /\s*,\s*/, $val]; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
0
|
croak "expected option value after $key"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
26
|
|
100
|
|
|
235
|
$ret{$key} ||= []; |
49
|
26
|
100
|
|
|
|
53
|
push @{ $ret{$key} }, ref $val ? @{ $val } : $val; |
|
26
|
|
|
|
|
149
|
|
|
2
|
|
|
|
|
9
|
|
50
|
|
|
|
|
|
|
} continue { |
51
|
26
|
|
|
|
|
110
|
$self->skipspace; |
52
|
26
|
|
|
|
|
539
|
$linestr = $self->get_linestr(); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
23
|
|
|
|
|
60
|
my $options = { map { |
56
|
61
|
|
|
|
|
1242
|
my $key = $_; |
57
|
5
|
|
|
|
|
38
|
$key eq 'is' |
58
|
23
|
100
|
|
|
|
159
|
? ($key => { map { ($_ => 1) } @{ $ret{$key} } }) |
|
5
|
|
|
|
|
15
|
|
59
|
|
|
|
|
|
|
: ($key => $ret{$key}) |
60
|
|
|
|
|
|
|
} keys %ret }; |
61
|
|
|
|
|
|
|
|
62
|
61
|
|
|
|
|
2770
|
$self->options($options); |
63
|
|
|
|
|
|
|
|
64
|
61
|
|
|
|
|
348
|
return $options; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |