line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::HashType; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
84512
|
use strict; |
|
6
|
|
|
|
|
39
|
|
|
6
|
|
|
|
|
172
|
|
4
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
202
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
2792
|
use Mo qw(build is); |
|
6
|
|
|
|
|
3110
|
|
|
6
|
|
|
|
|
32
|
|
7
|
6
|
|
|
6
|
|
12206
|
use Mo::utils qw(check_bool check_length check_number check_required); |
|
6
|
|
|
|
|
96455
|
|
|
6
|
|
|
|
|
113
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.01; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has active => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has id => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has name => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub BUILD { |
24
|
11
|
|
|
11
|
0
|
8771
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Check active. |
27
|
11
|
100
|
|
|
|
57
|
if (! defined $self->{'active'}) { |
28
|
6
|
|
|
|
|
15
|
$self->{'active'} = 1; |
29
|
|
|
|
|
|
|
} |
30
|
11
|
|
|
|
|
49
|
check_bool($self, 'active'); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Check id. |
33
|
10
|
|
|
|
|
213
|
check_number($self, 'id'); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Check hash name. |
36
|
9
|
|
|
|
|
111
|
check_required($self, 'name'); |
37
|
8
|
|
|
|
|
66
|
check_length($self, 'name', 50); |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
99
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=encoding utf8 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Data::HashType - Data object for hash type. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
use Data::HashType; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $obj = Data::HashType->new(%params); |
59
|
|
|
|
|
|
|
my $active = $obj->active; |
60
|
|
|
|
|
|
|
my $id = $obj->id; |
61
|
|
|
|
|
|
|
my $name = $obj->name; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 C<new> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $obj = Data::HashType->new(%params); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Constructor. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over 8 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * C<active> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Flag for activity of hash type. |
76
|
|
|
|
|
|
|
Possible valuea are 0/1. |
77
|
|
|
|
|
|
|
Default value is 1 (active). |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * C<id> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Id of record. |
82
|
|
|
|
|
|
|
Id could be number. |
83
|
|
|
|
|
|
|
It's optional. |
84
|
|
|
|
|
|
|
Default value is undef. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * C<name> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Hash type name. |
89
|
|
|
|
|
|
|
Maximal length of value is 50 characters. |
90
|
|
|
|
|
|
|
It's required. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Returns instance of object. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 C<active> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $active = $obj->active; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Get active flag. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns 0/1. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 C<id> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $id = $obj->id; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Get hash type record id. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns number. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 C<name> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $name = $obj->name; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Get hash type name. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns string. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 EXAMPLE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=for comment filename=create_and_print_hash_type.pl |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
use strict; |
125
|
|
|
|
|
|
|
use warnings; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
use Data::HashType; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $obj = Data::HashType->new( |
130
|
|
|
|
|
|
|
'active' => 1, |
131
|
|
|
|
|
|
|
'id' => 10, |
132
|
|
|
|
|
|
|
'name' => 'SHA256', |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Print out. |
136
|
|
|
|
|
|
|
print 'Name: '.$obj->name."\n"; |
137
|
|
|
|
|
|
|
print 'Active: '.$obj->active."\n"; |
138
|
|
|
|
|
|
|
print 'Id: '.$obj->id."\n"; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Output: |
141
|
|
|
|
|
|
|
# Name: SHA256 |
142
|
|
|
|
|
|
|
# Active: 1 |
143
|
|
|
|
|
|
|
# Id: 10 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L<Mo>, |
148
|
|
|
|
|
|
|
L<Mo::utils>. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 REPOSITORY |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Data-HashType> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L<http://skim.cz> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
© 2023 Michal Josef Špaček |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
BSD 2-Clause License |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 VERSION |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
0.01 |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |