| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Form::Base; |
|
2
|
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
549694
|
use strict; |
|
|
14
|
|
|
|
|
39
|
|
|
|
14
|
|
|
|
|
2233
|
|
|
4
|
14
|
|
|
14
|
|
151
|
use warnings; |
|
|
14
|
|
|
|
|
29
|
|
|
|
14
|
|
|
|
|
1032
|
|
|
5
|
14
|
|
|
14
|
|
13829
|
use UNIVERSAL::moniker; |
|
|
14
|
|
|
|
|
143
|
|
|
|
14
|
|
|
|
|
2042
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Form::Base - Base class for other Form classes |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This provides a base class for Form classes that need attributes that |
|
16
|
|
|
|
|
|
|
can be set either as class or instance methods. This is really a |
|
17
|
|
|
|
|
|
|
standalone CPAN module waiting to escape once we decide it's a sensible |
|
18
|
|
|
|
|
|
|
approach to things. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 mk_attributes |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__PACKAGE__->mk_attributes(qw/ decorators fields name /); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Any subclass which wishes to have other attributes that follow this same |
|
27
|
|
|
|
|
|
|
pattern (inheritiable class data which gets copied into instance data |
|
28
|
|
|
|
|
|
|
when a form is created), can set them up using mk_attributes. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
14
|
|
|
14
|
|
85
|
use base qw/Class::Data::Inheritable/; |
|
|
14
|
|
|
|
|
30
|
|
|
|
14
|
|
|
|
|
22690
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub mk_attributes { |
|
35
|
0
|
|
|
0
|
1
|
|
my ($class, @att) = @_; |
|
36
|
14
|
|
|
14
|
|
6303
|
no strict 'refs'; |
|
|
14
|
|
|
|
|
31
|
|
|
|
14
|
|
|
|
|
10138
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
foreach my $att (@att) { |
|
39
|
0
|
|
|
|
|
|
my $inner = "_$att"; |
|
40
|
0
|
|
|
|
|
|
my $add = "add_$att"; |
|
41
|
0
|
|
|
|
|
|
my $addalias = "_add_$att"; |
|
42
|
0
|
|
|
|
|
|
my $alias = "_att_$att"; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$class->mk_classdata($inner); |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
*{"$class\::$alias"} = sub { |
|
47
|
0
|
|
|
0
|
|
|
my $proto = shift; |
|
48
|
0
|
0
|
|
|
|
|
if (ref $proto) { |
|
49
|
0
|
0
|
|
|
|
|
if (@_) { $proto->{$att} = shift } |
|
|
0
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $proto->{$att}; |
|
51
|
|
|
|
|
|
|
} else { |
|
52
|
0
|
|
|
|
|
|
$proto->$inner(@_); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
0
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
*{"$class\::$att"} = \&{"$class\::$alias"} |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
unless *{"$class\::$att"}{CODE}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
*{"$class\::$addalias"} = sub { |
|
60
|
0
|
|
|
0
|
|
|
my $proto = shift; |
|
61
|
0
|
0
|
|
|
|
|
$proto->$alias([ @{ $proto->$alias || [] }, @_ ]); |
|
|
0
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $proto; |
|
63
|
0
|
|
|
|
|
|
}; |
|
64
|
0
|
|
|
|
|
|
*{"$class\::$add"} = \&{"$class\::$addalias"} |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
unless *{"$class\::$add"}{CODE}; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
*{"$class\::new"} = sub { |
|
69
|
0
|
|
|
0
|
|
|
my ($class, $args) = @_; |
|
70
|
0
|
|
0
|
|
|
|
my $self = bless {}, ref $class || $class; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Copy class-data down into instance |
|
73
|
0
|
|
|
|
|
|
foreach my $att (@att) { |
|
74
|
0
|
|
|
|
|
|
my $att2 = "_att_$att"; |
|
75
|
0
|
|
0
|
|
|
|
$self->$att2($class->$att2() || $class->moniker); |
|
76
|
|
|
|
|
|
|
# Why the moniker? |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
while (my ($att, $val) = each %$args) { |
|
80
|
0
|
0
|
|
|
|
|
if (ref($val) eq "ARRAY") { |
|
81
|
0
|
|
|
|
|
|
my $meth = "add_$att"; |
|
82
|
0
|
|
|
|
|
|
$self->$meth(@$val); |
|
83
|
|
|
|
|
|
|
} else { |
|
84
|
0
|
|
|
|
|
|
$self->$att($val); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
|
|
|
|
|
return $self; |
|
88
|
0
|
|
|
|
|
|
}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |