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