line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE |
2
|
|
|
|
|
|
|
MooseX::Declare::Context::WithOptions; |
3
|
|
|
|
|
|
|
|
4
|
24
|
|
|
24
|
|
10803
|
use Moose::Role; |
|
24
|
|
|
|
|
35
|
|
|
24
|
|
|
|
|
140
|
|
5
|
24
|
|
|
24
|
|
91698
|
use Carp qw/croak/; |
|
24
|
|
|
|
|
50
|
|
|
24
|
|
|
|
|
1263
|
|
6
|
24
|
|
|
24
|
|
118
|
use MooseX::Types::Moose 0.20 qw/HashRef/; |
|
24
|
|
|
|
|
650
|
|
|
24
|
|
|
|
|
211
|
|
7
|
|
|
|
|
|
|
|
8
|
24
|
|
|
24
|
|
91834
|
use namespace::clean -except => 'meta'; |
|
24
|
|
|
|
|
49
|
|
|
24
|
|
|
|
|
225
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has options => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => HashRef, |
13
|
|
|
|
|
|
|
default => sub { {} }, |
14
|
|
|
|
|
|
|
lazy => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub strip_options { |
18
|
63
|
|
|
63
|
0
|
106
|
my ($self) = @_; |
19
|
63
|
|
|
|
|
96
|
my %ret; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Make errors get reported from right place in source file |
22
|
63
|
|
|
|
|
247
|
local $Carp::Internal{'MooseX::Declare'} = 1; |
23
|
63
|
|
|
|
|
171
|
local $Carp::Internal{'Devel::Declare'} = 1; |
24
|
|
|
|
|
|
|
|
25
|
63
|
|
|
|
|
178
|
$self->skipspace; |
26
|
63
|
|
|
|
|
980
|
my $linestr = $self->get_linestr; |
27
|
|
|
|
|
|
|
|
28
|
63
|
|
|
|
|
866
|
while (substr($linestr, $self->offset, 1) !~ /[{;]/) { |
29
|
28
|
|
|
|
|
393
|
my $key = $self->strip_name; |
30
|
28
|
100
|
|
|
|
785
|
if (!defined $key) { |
31
|
2
|
100
|
|
|
|
190
|
croak 'expected option name' |
32
|
|
|
|
|
|
|
if keys %ret; |
33
|
1
|
|
|
|
|
5
|
return; # This is the case when { class => 'foo' } happens |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
26
|
50
|
|
|
|
156
|
croak "unknown option name '$key'" |
37
|
|
|
|
|
|
|
unless $key =~ /^(extends|with|is)$/; |
38
|
|
|
|
|
|
|
|
39
|
26
|
|
|
|
|
73
|
my $val = $self->strip_name; |
40
|
26
|
100
|
|
|
|
656
|
if (!defined $val) { |
41
|
2
|
50
|
|
|
|
18
|
if (defined($val = $self->strip_proto)) { |
42
|
2
|
|
|
|
|
124
|
$val = [split /\s*,\s*/, $val]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
0
|
|
|
|
|
0
|
croak "expected option value after $key"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
26
|
|
100
|
|
|
151
|
$ret{$key} ||= []; |
50
|
26
|
100
|
|
|
|
53
|
push @{ $ret{$key} }, ref $val ? @{ $val } : $val; |
|
26
|
|
|
|
|
105
|
|
|
2
|
|
|
|
|
6
|
|
51
|
|
|
|
|
|
|
} continue { |
52
|
26
|
|
|
|
|
70
|
$self->skipspace; |
53
|
26
|
|
|
|
|
345
|
$linestr = $self->get_linestr(); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
23
|
|
|
|
|
46
|
my $options = { map { |
57
|
61
|
|
|
|
|
991
|
my $key = $_; |
58
|
5
|
|
|
|
|
39
|
$key eq 'is' |
59
|
23
|
100
|
|
|
|
115
|
? ($key => { map { ($_ => 1) } @{ $ret{$key} } }) |
|
5
|
|
|
|
|
13
|
|
60
|
|
|
|
|
|
|
: ($key => $ret{$key}) |
61
|
|
|
|
|
|
|
} keys %ret }; |
62
|
|
|
|
|
|
|
|
63
|
61
|
|
|
|
|
2157
|
$self->options($options); |
64
|
|
|
|
|
|
|
|
65
|
61
|
|
|
|
|
261
|
return $options; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |