| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Badger::Data::Type::Class; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use Badger::Debug ':dump'; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
|
|
use Badger::Class |
|
5
|
2
|
|
|
|
|
17
|
version => 0.01, |
|
6
|
|
|
|
|
|
|
debug => 0, |
|
7
|
|
|
|
|
|
|
uber => 'Badger::Class', |
|
8
|
|
|
|
|
|
|
# words => 'FACETS', |
|
9
|
|
|
|
|
|
|
constants => 'ARRAY DELIMITER', |
|
10
|
|
|
|
|
|
|
hooks => { |
|
11
|
|
|
|
|
|
|
type => \&type, |
|
12
|
|
|
|
|
|
|
size => \&size, |
|
13
|
|
|
|
|
|
|
facets => \&facets, |
|
14
|
2
|
|
|
2
|
|
12
|
}; |
|
|
2
|
|
|
|
|
2
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub type { |
|
18
|
2
|
|
|
2
|
1
|
5
|
my ($self, $type) = @_; |
|
19
|
2
|
|
|
|
|
3
|
$self->debug("set type to $type") if DEBUG; |
|
20
|
2
|
|
|
|
|
23
|
$self->method( type => $type ); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub size { |
|
25
|
2
|
|
|
2
|
1
|
15
|
my ($self, $size) = @_; |
|
26
|
2
|
|
|
|
|
3
|
$self->debug("set size to $size") if DEBUG; |
|
27
|
2
|
|
|
|
|
5
|
$self->method( size => $size ); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub facets { |
|
32
|
2
|
|
|
2
|
1
|
4
|
my ($self, $facets) = @_; |
|
33
|
2
|
|
|
|
|
10
|
my $current = $self->var_default( FACETS => [ ] ); |
|
34
|
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
5
|
foreach ($facets, $current) { |
|
36
|
4
|
100
|
|
|
|
22
|
$_ = [ split DELIMITER ] |
|
37
|
|
|
|
|
|
|
unless ref eq ARRAY; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
5
|
push(@$current, @$facets); |
|
41
|
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
2
|
$self->debug("merged facets are ", $self->dump_data($facets)) if DEBUG; |
|
43
|
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
8
|
$self->var( FACETS => $current ); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Badger::Data::Type::Class - metaprogramming module for data type classes |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This module implements a subclass of L for creating data |
|
60
|
|
|
|
|
|
|
types. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This module implements the following methods in addition to those inherited |
|
65
|
|
|
|
|
|
|
from the L base class. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 type($type) |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This method implements the C import hook for specifying the base data |
|
70
|
|
|
|
|
|
|
type. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 size($size) |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This method implements the C import hook for specifying the data size. |
|
75
|
|
|
|
|
|
|
NOTE: subject to change |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 facets($facets) |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This method implements the C import hook for specifying validation |
|
80
|
|
|
|
|
|
|
facets for a data type. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 IMPORT HOOKS |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The following hooks can be specified when the module is imported via C |
|
85
|
|
|
|
|
|
|
They correspond directly to the methods documented above. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 type |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 size |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 facets |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Andy Wardley L |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Copyright (C) 2008-2012 Andy Wardley. All Rights Reserved. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
102
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L, |
|
107
|
|
|
|
|
|
|
L. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Local Variables: |
|
112
|
|
|
|
|
|
|
# mode: perl |
|
113
|
|
|
|
|
|
|
# perl-indent-level: 4 |
|
114
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
|
115
|
|
|
|
|
|
|
# End: |
|
116
|
|
|
|
|
|
|
# |
|
117
|
|
|
|
|
|
|
# vim: expandtab shiftwidth=4: |