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