line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroMason::HasParams; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
###################################################################### |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub defaults { |
6
|
14
|
|
|
14
|
0
|
434
|
(shift)->NEXT('defaults'), params => [ {} ] |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
###################################################################### |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub assembler_rules { |
12
|
9
|
|
|
9
|
1
|
25
|
my $self = shift; |
13
|
9
|
|
|
|
|
31
|
$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
|
1744
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
41
|
50
|
|
|
|
66
|
my @params = $self->{params} ? @{$self->{params}} : (); |
|
41
|
|
|
|
|
59
|
|
23
|
|
|
|
|
|
|
|
24
|
41
|
50
|
33
|
|
|
142
|
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
|
|
|
|
8
|
if ( my $associate = $self->{associate} ) { |
30
|
0
|
|
|
|
|
0
|
return $associate->param( @_ ); |
31
|
|
|
|
|
|
|
} |
32
|
4
|
|
50
|
|
|
7
|
$self->{params} ||= [ {} ]; |
33
|
4
|
|
50
|
|
|
8
|
$self->{params}[0] ||= {}; |
34
|
4
|
|
|
|
|
6
|
my $target = $self->{params}[0]; |
35
|
4
|
50
|
|
|
|
7
|
if ( $self->{case_sensitive} ) { |
36
|
0
|
|
|
|
|
0
|
%$target = ( %$target, @_ ); |
37
|
|
|
|
|
|
|
} else { |
38
|
4
|
|
|
|
|
10
|
my %hash = @_; |
39
|
4
|
|
|
|
|
10
|
%$target = ( %$target, map { lc($_) => $hash{$_} } keys %hash ); |
|
4
|
|
|
|
|
28
|
|
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
|
|
|
|
70
|
my $key = $self->{case_sensitive} ? shift : lc( shift ); |
48
|
|
|
|
|
|
|
# warn "get params $key: $#params\n"; |
49
|
37
|
|
|
|
|
49
|
foreach my $param ( @params ) { |
50
|
|
|
|
|
|
|
# warn "get params $param: $key\n"; |
51
|
|
|
|
|
|
|
my $case_key = ( exists $param->{ $key } ) ? $key : |
52
|
41
|
50
|
|
|
|
76
|
( ! $self->{case_sensitive} ) ? ( grep { lc eq $key } keys %$param )[0] : undef; |
|
15
|
100
|
|
|
|
32
|
|
53
|
41
|
100
|
|
|
|
65
|
next unless defined $case_key; |
54
|
33
|
|
|
|
|
53
|
my $value = $param->{ $case_key }; |
55
|
|
|
|
|
|
|
# warn "get params $param: $key ($case_key) = $value\n"; |
56
|
33
|
100
|
|
|
|
95
|
return( ( ref($value) eq 'ARRAY' ) ? @$value : $value ) |
57
|
|
|
|
|
|
|
} |
58
|
4
|
50
|
|
|
|
13
|
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
|
|
|
|
|
7
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
###################################################################### |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |