line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Workflow::Persister::RandomId; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
4308
|
use warnings; |
|
18
|
|
|
|
|
48
|
|
|
18
|
|
|
|
|
755
|
|
4
|
18
|
|
|
18
|
|
124
|
use strict; |
|
18
|
|
|
|
|
64
|
|
|
18
|
|
|
|
|
482
|
|
5
|
18
|
|
|
18
|
|
131
|
use base qw( Class::Accessor ); |
|
18
|
|
|
|
|
72
|
|
|
18
|
|
|
|
|
2889
|
|
6
|
|
|
|
|
|
|
|
7
|
18
|
|
|
18
|
|
2101
|
use constant DEFAULT_ID_LENGTH => 8; |
|
18
|
|
|
|
|
48
|
|
|
18
|
|
|
|
|
1290
|
|
8
|
18
|
|
|
18
|
|
125
|
use constant RANDOM_SEED => 26; |
|
18
|
|
|
|
|
58
|
|
|
18
|
|
|
|
|
1078
|
|
9
|
18
|
|
|
18
|
|
143
|
use constant CONSTANT_INCREMENT => 65; |
|
18
|
|
|
|
|
48
|
|
|
18
|
|
|
|
|
4702
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$Workflow::Persister::RandomId::VERSION = '1.62'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @FIELDS = qw( id_length ); |
14
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(@FIELDS); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
22
|
|
|
22
|
1
|
19098
|
my ( $class, $params ) = @_; |
18
|
22
|
|
|
|
|
72
|
my $self = bless {}, $class; |
19
|
22
|
|
100
|
|
|
215
|
my $length = $params->{id_length} || DEFAULT_ID_LENGTH; |
20
|
22
|
|
|
|
|
118
|
$self->id_length($length); |
21
|
22
|
|
|
|
|
468
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub pre_fetch_id { |
25
|
60
|
|
|
60
|
1
|
15768
|
my ( $self, $dbh ) = @_; |
26
|
|
|
|
|
|
|
return join '', |
27
|
60
|
|
|
|
|
214
|
map { chr int( rand RANDOM_SEED ) + CONSTANT_INCREMENT } |
|
508
|
|
|
|
|
2483
|
|
28
|
|
|
|
|
|
|
( 1 .. $self->id_length ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
1
|
946
|
sub post_fetch_id {return} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Workflow::Persister::RandomId - Persister to generate random ID |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 VERSION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This documentation describes version 1.62 of this package |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
<persister |
50
|
|
|
|
|
|
|
name="MyPersister" |
51
|
|
|
|
|
|
|
id_length="16" |
52
|
|
|
|
|
|
|
... |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Implementation for any persister to generate a random ID string. You |
57
|
|
|
|
|
|
|
can specify the length using the 'id_length' parameter, but normally |
58
|
|
|
|
|
|
|
the default (8 characters) is sufficient. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head3 new |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Instantiates a Workflow::Persister::RandomId object, this object can generate |
65
|
|
|
|
|
|
|
randon Id's based on the 'id_length' parameter provided. This parameter defaults |
66
|
|
|
|
|
|
|
to 8. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head3 pre_fetch_id |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L</pre_fetch_id> can then be used to generate/retrieve a random ID, generated |
71
|
|
|
|
|
|
|
adhering to the length specified in the constructor call. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head3 post_fetch_id |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This method is unimplemented at this time, please see the TODO. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 TODO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * Implement L</post_fetch_id> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Copyright (c) 2003-2023 Chris Winters. All rights reserved. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
90
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Please see the F<LICENSE> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHORS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Please see L<Workflow> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |