line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroMason::HasParams; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
###################################################################### |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub defaults { |
6
|
14
|
|
|
14
|
0
|
355
|
(shift)->NEXT('defaults'), params => [ {} ] |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
###################################################################### |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub assembler_rules { |
12
|
9
|
|
|
9
|
1
|
7
|
my $self = shift; |
13
|
9
|
|
|
|
|
19
|
$self->NEXT('assembler_rules', @_), |
14
|
|
|
|
|
|
|
init_args => 'local $m->{params} = [ ( @_ == 1 ) ? $_[0] : scalar(@_) ? { @_ } : (), $m->{params} ? @{$m->{params}} : () ];'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
###################################################################### |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub param { |
20
|
41
|
|
|
41
|
1
|
605
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
41
|
50
|
|
|
|
60
|
my @params = $self->{params} ? @{$self->{params}} : (); |
|
41
|
|
|
|
|
54
|
|
23
|
|
|
|
|
|
|
|
24
|
41
|
50
|
33
|
|
|
152
|
if ( scalar @_ == 0 ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return map( keys(%$_), @params ), |
26
|
0
|
0
|
|
|
|
0
|
$self->{associate} ? $self->{associate}->param() : () |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} elsif ( scalar @_ > 1 ) { |
29
|
4
|
50
|
|
|
|
9
|
if ( my $associate = $self->{associate} ) { |
30
|
0
|
|
|
|
|
0
|
return $associate->param( @_ ); |
31
|
|
|
|
|
|
|
} |
32
|
4
|
|
50
|
|
|
6
|
$self->{params} ||= [ {} ]; |
33
|
4
|
|
50
|
|
|
7
|
$self->{params}[0] ||= {}; |
34
|
4
|
|
|
|
|
2
|
my $target = $self->{params}[0]; |
35
|
4
|
50
|
|
|
|
7
|
if ( $self->{case_sensitive} ) { |
36
|
0
|
|
|
|
|
0
|
%$target = ( %$target, @_ ); |
37
|
|
|
|
|
|
|
} else { |
38
|
4
|
|
|
|
|
6
|
my %hash = @_; |
39
|
4
|
|
|
|
|
8
|
%$target = ( %$target, map { lc($_) => $hash{$_} } keys %hash ); |
|
4
|
|
|
|
|
24
|
|
40
|
|
|
|
|
|
|
# warn "set params $self->{params}[0]: " , %{ $self->{params}[0] }; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} elsif ( scalar @_ == 1 and ref( $_[0] ) ) { |
44
|
0
|
|
|
|
|
0
|
push @{$self->{params}}, shift(); |
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} else { |
47
|
37
|
50
|
|
|
|
55
|
my $key = $self->{case_sensitive} ? shift : lc( shift ); |
48
|
|
|
|
|
|
|
# warn "get params $key: $#params\n"; |
49
|
37
|
|
|
|
|
38
|
foreach my $param ( @params ) { |
50
|
|
|
|
|
|
|
# warn "get params $param: $key\n"; |
51
|
|
|
|
|
|
|
my $case_key = ( exists $param->{ $key } ) ? $key : |
52
|
41
|
50
|
|
|
|
72
|
( ! $self->{case_sensitive} ) ? ( grep { lc eq $key } keys %$param )[0] : undef; |
|
15
|
100
|
|
|
|
26
|
|
53
|
41
|
100
|
|
|
|
96
|
next unless defined $case_key; |
54
|
33
|
|
|
|
|
30
|
my $value = $param->{ $case_key }; |
55
|
|
|
|
|
|
|
# warn "get params $param: $key ($case_key) = $value\n"; |
56
|
33
|
100
|
|
|
|
98
|
return( ( ref($value) eq 'ARRAY' ) ? @$value : $value ) |
57
|
|
|
|
|
|
|
} |
58
|
4
|
50
|
|
|
|
10
|
if ( my $associate = $self->{associate} ) { |
59
|
|
|
|
|
|
|
my $case_key = ( $self->{case_sensitive} ) ? $key : |
60
|
0
|
0
|
|
|
|
0
|
( grep { lc eq $key } $associate->param() )[0]; |
|
0
|
|
|
|
|
0
|
|
61
|
0
|
|
|
|
|
0
|
return $associate->param( $case_key ); |
62
|
|
|
|
|
|
|
} |
63
|
4
|
|
|
|
|
8
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
###################################################################### |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |