| 1 | package DBIx::Class::Schema::PgLog::Structure; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use base qw/DBIx::Class::Schema/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | require DBIx::Class::Schema::PgLog::Structure::Log; | |||||||||||||||||||||||||||
| 9 | 3 | require DBIx::Class::Schema::PgLog::Structure::LogSet; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | DBIx::Class::Schema::PgLog::Structure | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 VERSION | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Version 0.03 | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | Perhaps a little code snippet. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | use DBIx::Class::Schema::PgLog::Structure; | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | my $foo = DBIx::Class::Schema::PgLog::Structure->new(); | ||||||||||||||||||||||||||||
| 31 | ... | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =cut | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 3 | __PACKAGE__->mk_group_accessors( simple => '_current_logset_container' ); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub _current_logset { | ||||||||||||||||||||||||||
|
Subroutine
_current_logset: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | 0 | my $ref = $self->_current_logset_container; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return $ref && $ref->{logset}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$ref && $ref->{'logset'}
MC/DC0%0/2
$ref && $ref->{'logset'}
$ref
$ref->{'logset'}
Truth table0%0/3
A && B
A= $refB= $ref->{'logset'}
| |||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head2 current_logset | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Returns the logset that is currently in process. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | This is localized to the scope of each transaction. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub current_logset { | ||||||||||||||||||||||||||
|
Subroutine
current_logset: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $self->throw_exception('Cannot set logset manually. Use txn_do.') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | if @args; | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # we only want to create a logset if the action (insert/update/delete) | ||||||||||||||||||||||||||||
| 61 | # is being run from txn_do -- the txn_do method in | ||||||||||||||||||||||||||||
| 62 | # DBIx::Class::Schema::PgLog sets local | ||||||||||||||||||||||||||||
| 63 | # _current_logset_container->{logset} & | ||||||||||||||||||||||||||||
| 64 | # _current_logset_container->{args} variables in the scope | ||||||||||||||||||||||||||||
| 65 | # of each transaction | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( defined $self->_current_logset_container | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->_current_logset_container and defined $self->_current_logset_container->{"logset"}
MC/DC0%0/2
defined $self->_current_logset_container and defined $self->_current_logset_container->{"logset"}
defined $self->_current_logset_container
defined $self->_current_logset_container->{"logset"}
Truth table0%0/3
A and B
A= defined $self->_current_logset_containerB= defined $self->_current_logset_container->{"logset"}
| |||||||||||||||||||||||||||||
| 67 | && defined $self->_current_logset_container->{logset} ) | ||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | my $id = $self->_current_logset; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | unless ($id) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | #Add LogSet Here | ||||||||||||||||||||||||||||
| 74 | 0 | my $txn_args = $self->_current_logset_container->{args}; | |||||||||||||||||||||||||||
| 75 | 0 | my $logset_data = {}; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if($txn_args) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $logset_data->{Epoch} = exists($txn_args->{Epoch})?$txn_args->{Epoch}:time(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $logset_data->{UserId} = exists($txn_args->{UserId})?$txn_args->{UserId}:0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | $logset_data->{Description} = exists($txn_args->{Description})?$txn_args->{Description}:""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | my $logset = $self->resultset('PgLogLogSet')->create( $logset_data ); | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | $self->_current_logset_container->{logset} = $logset->Id; | |||||||||||||||||||||||||||
| 85 | 0 | $id = $logset->Id; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | return $id; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | return; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub pg_log_create_log { | ||||||||||||||||||||||||||
|
Subroutine
pg_log_create_log: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 98 | 0 | my $log_data = shift; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | my $logset = $self->current_logset; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if(defined($self->_current_logset_container)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | my $txn_args = $self->_current_logset_container->{args}; | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | if($txn_args && $logset) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$txn_args and $logset
MC/DC0%0/2
$txn_args and $logset
$txn_args
$logset
Truth table0%0/3
A and B
A= $txn_argsB= $logset
| |||||||||||||||||||||||||||||
| 105 | 0 | $log_data->{LogSetId} = $logset; | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | $log_data->{Epoch} = exists($txn_args->{Epoch})?$txn_args->{Epoch}:time(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $log_data->{UserId} = exists($txn_args->{UserId})?$txn_args->{UserId}:0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | $self->resultset('PgLogLog')->create( $log_data ); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 3 | 1; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | Sheeju Alex, C<< <sheeju at exceleron.com> >> | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =head1 BUGS | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | Please report any bugs or feature requests to C<bug-dbix-class-pglog at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 124 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-PgLog>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 125 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | perldoc DBIx::Class::Schema::PgLog::Structure | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | You can also look for information at: | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =over 4 | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-PgLog> | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | L<http://annocpan.org/dist/DBIx-Class-PgLog> | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | L<http://cpanratings.perl.org/d/DBIx-Class-PgLog> | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | L<http://search.cpan.org/dist/DBIx-Class-PgLog/> | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =back | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | Copyright 2013 Sheeju Alex. | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 168 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||||||||||||||||
| 169 | copy of the full license at: | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||||||||||||||||
| 174 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||||||||||||||||
| 175 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||||||||||||||||
| 176 | or distribute the Package, if you do not accept this license. | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||||||||||||||||
| 179 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||||||||||||||||
| 180 | your Modified Version complies with the requirements of this license. | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | This license does not grant you the right to use any trademark, service | ||||||||||||||||||||||||||||
| 183 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||||||||||||||||
| 186 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||||||||||||||||||
| 187 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||||||||||||||||
| 188 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||||||||||||||||
| 189 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||||||||||||||||
| 190 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||||||||||||||||
| 191 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||||||||||||||||
| 192 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||||||||||||||||
| 195 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||||||||||||||||
| 196 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||||||||||||||||
| 197 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||||||||||||||||
| 198 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||||||||||||||||
| 199 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||||||||||||||||
| 200 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||||||||||||||||
| 201 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =cut | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 3 | 1; # End of DBIx::Class::Schema::PgLog::Structure | |||||||||||||||||||||||||||