line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Widget::Accessor; |
2
|
|
|
|
|
|
|
|
3
|
88
|
|
|
88
|
|
601
|
use warnings; |
|
88
|
|
|
|
|
182
|
|
|
88
|
|
|
|
|
2779
|
|
4
|
88
|
|
|
88
|
|
524
|
use strict; |
|
88
|
|
|
|
|
186
|
|
|
88
|
|
|
|
|
2733
|
|
5
|
88
|
|
|
88
|
|
555
|
use base 'Class::Accessor::Chained::Fast'; |
|
88
|
|
|
|
|
163
|
|
|
88
|
|
|
|
|
98765
|
|
6
|
88
|
|
|
88
|
|
645406
|
use Carp qw/croak/; |
|
88
|
|
|
|
|
230
|
|
|
88
|
|
|
|
|
60170
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
*attrs = \&attributes; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
HTML::Widget::Accessor - Accessor Class |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use base 'HTML::Widget::Accessor'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Accessor Class. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 attributes |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 attrs |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Arguments: %attributes |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Arguments: \%attributes |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Return Value: $self |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Arguments: none |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Return Value: \%attributes |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Accepts either a list of key/value pairs, or a hash-ref. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$w->attributes( $key => $value ); |
41
|
|
|
|
|
|
|
$w->attributes( { $key => $value } ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Returns the object reference, to allow method chaining. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
As of v1.10, passing a hash-ref no longer deletes current |
46
|
|
|
|
|
|
|
attributes, instead the attributes are added to the current attributes |
47
|
|
|
|
|
|
|
hash. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This means the attributes hash-ref can no longer be emptied using |
50
|
|
|
|
|
|
|
C<$w->attributes( { } );>. Instead, you may use |
51
|
|
|
|
|
|
|
C<%{ $w->attributes } = ();>. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
As a special case, if no arguments are passed, the return value is a |
54
|
|
|
|
|
|
|
hash-ref of attributes instead of the object reference. This provides |
55
|
|
|
|
|
|
|
backwards compatability to support: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$w->attributes->{key} = $value; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
L is an alias for L. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub attributes { |
64
|
2359
|
|
|
2359
|
1
|
5163
|
my $self = shift; |
65
|
|
|
|
|
|
|
|
66
|
2359
|
100
|
|
|
|
6339
|
$self->{attributes} = {} if not defined $self->{attributes}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# special-case to support $w->attrs->{key} = value |
69
|
2359
|
100
|
|
|
|
15624
|
return $self->{attributes} unless @_; |
70
|
|
|
|
|
|
|
|
71
|
3
|
|
|
|
|
14
|
my %attrs = |
72
|
|
|
|
|
|
|
( scalar(@_) == 1 ) |
73
|
6
|
100
|
|
|
|
20
|
? %{ $_[0] } |
74
|
|
|
|
|
|
|
: @_; |
75
|
|
|
|
|
|
|
|
76
|
6
|
|
|
|
|
30
|
$self->{attributes}->{$_} = $attrs{$_} for keys %attrs; |
77
|
|
|
|
|
|
|
|
78
|
6
|
|
|
|
|
20
|
return $self; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 mk_attr_accessors |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Arguments: @names |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Return Value: @names |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub mk_attr_accessors { |
90
|
705
|
|
|
705
|
1
|
3443
|
my ( $self, @names ) = @_; |
91
|
705
|
|
33
|
|
|
5625
|
my $class = ref $self || $self; |
92
|
705
|
|
|
|
|
1815
|
for my $name (@names) { |
93
|
88
|
|
|
88
|
|
629
|
no strict 'refs'; |
|
88
|
|
|
|
|
216
|
|
|
88
|
|
|
|
|
36370
|
|
94
|
1762
|
|
|
|
|
12474
|
*{"$class\::$name"} = sub { |
95
|
884
|
100
|
33
|
884
|
|
10148
|
return ( $_[0]->{attributes}->{$name} || $_[0] ) unless @_ > 1; |
96
|
151
|
|
|
|
|
315
|
my $self = shift; |
97
|
151
|
50
|
|
|
|
906
|
$self->{attributes}->{$name} = ( @_ == 1 ? $_[0] : [@_] ); |
98
|
151
|
|
|
|
|
691
|
return $self; |
99
|
|
|
|
|
|
|
} |
100
|
1762
|
|
|
|
|
9826
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub _instantiate { |
104
|
422
|
|
|
422
|
|
1045
|
my ( $self, $class, @args ) = @_; |
105
|
422
|
|
|
|
|
1057
|
my $file = $class . ".pm"; |
106
|
422
|
|
|
|
|
2244
|
$file =~ s{::}{/}g; |
107
|
422
|
|
|
|
|
1008
|
eval { require $file }; |
|
422
|
|
|
|
|
6834
|
|
108
|
422
|
50
|
|
|
|
1813
|
croak qq/Couldn't load class "$class", "$@"/ if $@; |
109
|
422
|
|
|
|
|
4499
|
return $class->new(@args); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Sebastian Riedel, C |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 LICENSE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
119
|
|
|
|
|
|
|
the same terms as Perl itself. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |