| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::Class::AuditAny::AuditContext::ChangeSet; |
|
2
|
14
|
|
|
14
|
|
8918
|
use strict; |
|
|
14
|
|
|
|
|
43
|
|
|
|
14
|
|
|
|
|
492
|
|
|
3
|
14
|
|
|
14
|
|
87
|
use warnings; |
|
|
14
|
|
|
|
|
39
|
|
|
|
14
|
|
|
|
|
413
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Default 'ChangeSet' context object class for DBIx::Class::AuditAny |
|
6
|
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
83
|
use Moo; |
|
|
14
|
|
|
|
|
38
|
|
|
|
14
|
|
|
|
|
103
|
|
|
8
|
14
|
|
|
14
|
|
24091
|
use MooX::Types::MooseLike::Base qw(:all); |
|
|
14
|
|
|
|
|
62
|
|
|
|
14
|
|
|
|
|
5356
|
|
|
9
|
|
|
|
|
|
|
extends 'DBIx::Class::AuditAny::AuditContext'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
DBIx::Class::AuditAny::AuditContext::ChangeSet - Default 'ChangeSet' context object |
|
14
|
|
|
|
|
|
|
class for DBIx::Class::AuditAny |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This object class represents a "set" of changes grouped together, typically all applied within |
|
19
|
|
|
|
|
|
|
the scope of a single transaction. The changes can span across multiple individual changes, |
|
20
|
|
|
|
|
|
|
which can also represent changes to multiple different columns. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This class is used internally and should not be used directly. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
14
|
|
|
14
|
|
132
|
use Time::HiRes qw(gettimeofday tv_interval); |
|
|
14
|
|
|
|
|
35
|
|
|
|
14
|
|
|
|
|
114
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
32
|
|
|
32
|
|
936
|
sub _build_tiedContexts { [] } |
|
29
|
|
|
|
|
|
|
sub _build_local_datapoint_data { |
|
30
|
42
|
|
|
42
|
|
567
|
my $self = shift; |
|
31
|
42
|
|
|
|
|
222
|
return { map { $_->name => $_->get_value($self) } $self->get_context_datapoints('set') }; |
|
|
79
|
|
|
|
|
663
|
|
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Docs regarding the API/purpose of the attributes and methods in this class still TBD... |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 changes |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 finished |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 changeset_ts |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 start_timeofday |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 changeset_finish_ts |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 changeset_elapsed |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has 'changes', is => 'ro', isa => ArrayRef, default => sub {[]}; |
|
53
|
|
|
|
|
|
|
has 'finished', is => 'rw', isa => Bool, default => sub{0}, init_arg => undef; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has 'changeset_ts', is => 'ro', isa => InstanceOf['DateTime'], lazy => 1, default => sub { (shift)->get_dt }; |
|
56
|
|
|
|
|
|
|
has 'start_timeofday', is => 'ro', default => sub { [gettimeofday] }; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has 'changeset_finish_ts', is => 'rw', isa => Maybe[InstanceOf['DateTime']], default => sub{undef}; |
|
59
|
|
|
|
|
|
|
has 'changeset_elapsed', is => 'rw', default => sub{undef}; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub BUILD { |
|
62
|
49
|
|
|
49
|
0
|
497
|
my $self = shift; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Init |
|
65
|
49
|
|
|
|
|
917
|
$self->changeset_ts; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 all_changes |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 count_changes |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 all_column_changes |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 add_changes |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 finish |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
47
|
|
|
47
|
1
|
116
|
sub all_changes { @{(shift)->changes} } |
|
|
47
|
|
|
|
|
243
|
|
|
83
|
0
|
|
|
0
|
1
|
0
|
sub count_changes { scalar(@{(shift)->changes}) } |
|
|
0
|
|
|
|
|
0
|
|
|
84
|
5
|
|
|
5
|
1
|
858
|
sub all_column_changes { map { $_->all_column_changes } (shift)->all_changes } |
|
|
5
|
|
|
|
|
23
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub add_changes { |
|
87
|
98
|
|
|
98
|
1
|
922
|
my ($self, @ChangeContexts) = @_; |
|
88
|
|
|
|
|
|
|
|
|
89
|
98
|
50
|
|
|
|
1834
|
die "Cannot add_changes to finished ChangeSet!" if ($self->finished); |
|
90
|
|
|
|
|
|
|
|
|
91
|
98
|
|
|
|
|
1011
|
foreach my $ChangeContext (@ChangeContexts) { |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# New: It is now possible that there is no attached ChangeSet yet, since ChangeContext |
|
94
|
|
|
|
|
|
|
# is now created -before- the action operation is executed, and thus before |
|
95
|
|
|
|
|
|
|
# a changeset is automatically started (we do this so we don't have to worry |
|
96
|
|
|
|
|
|
|
# about exceptions). But by the time ->record() is called, we know the operation |
|
97
|
|
|
|
|
|
|
# has succeeded, and we also know that a new changeset has been created if the |
|
98
|
|
|
|
|
|
|
# operation was not already wrapped in a transaction. Se we just set it now: |
|
99
|
98
|
100
|
|
|
|
1751
|
$ChangeContext->ChangeSetContext($self) unless ($ChangeContext->ChangeSetContext); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Extra check for good measure: |
|
102
|
98
|
50
|
|
|
|
5579
|
die "Attempted to add changes attached to a different changeset!" |
|
103
|
|
|
|
|
|
|
unless ($self == $ChangeContext->ChangeSetContext); |
|
104
|
|
|
|
|
|
|
|
|
105
|
98
|
|
|
|
|
795
|
push @{$self->changes}, $ChangeContext; |
|
|
98
|
|
|
|
|
832
|
|
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub finish { |
|
111
|
47
|
|
|
47
|
1
|
578
|
my $self = shift; |
|
112
|
47
|
50
|
|
|
|
837
|
return if ($self->finished); |
|
113
|
|
|
|
|
|
|
|
|
114
|
47
|
|
|
|
|
564
|
$self->changeset_finish_ts($self->get_dt); |
|
115
|
47
|
|
|
|
|
59308
|
$self->changeset_elapsed(sprintf('%.8g',tv_interval($self->start_timeofday))); |
|
116
|
|
|
|
|
|
|
|
|
117
|
47
|
|
|
|
|
2031
|
return $self->finished(1); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L<DBIx::Class::AuditAny> |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L<DBIx::Class> |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=back |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SUPPORT |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
IRC: |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Join #rapidapp on irc.perl.org. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Henry Van Styn <vanstyn@cpan.org> |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This software is copyright (c) 2012-2015 by IntelliTree Solutions llc. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
153
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |