blib/lib/DBIx/Class/ResultSet/AuditLog.pm

filter: Statementstmt 92.3% 12 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 90.0% 18 / 20 CC 1 SCAR 1.8
CC
1
Cov
92%
update
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Build ↑ Summary blib/lib/DBIx/Class/Schema/AuditLog/Structure/Action.pm »
1 package DBIx::Class::ResultSet::AuditLog;
2 12 $DBIx::Class::ResultSet::AuditLog::VERSION = '0.6.2';
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use base "DBIx::Class::ResultSet";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 sub delete {
10 7 ▶ shift->delete_all;
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
11 };
12  
13  
14 sub update {
15 0 ▶ shift->update_all(@_);
Subroutine update: not called CC=1 SCAR=6.9
Pod documented
16 }
17  
18 12 1;
19  
20 __END__
21  
22 =pod
23  
24 =encoding UTF-8
25  
26 =head1 NAME
27  
28 DBIx::Class::ResultSet::AuditLog
29  
30 =head1 VERSION
31  
32 version 0.6.2
33  
34 =head1 SYNOPSIS
35  
36 Either create your own resultset-classes for each audited result-class, and load
37 AuditLogs resultset-component:
38  
39 package MySchema::ResultSet::MyAuditedSource;
40
41 use base "DBIx::Class::ResultSet"; # or use Moose and MooseX::NonMoose;
42  
43 __PACKAGE__->load_components("ResultSet::AuditLog");
44  
45 Or set the default resultset-class in your Schema:
46  
47 package MySchema;
48  
49 use base "DBIx::Class::Schema";
50  
51 ...
52  
53 __PACKAGE__->load_namespaces(
54 default_resultset_class => "AuditLog"
55 );
56  
57 =head1 DESCRIPTION
58  
59 This resultset class enables logging for database updates made by calling
60 L<DBIx::Class::ResultSet/delete> and L<DBIx::Class::ResultSet/update>.
61 This includes any updates made by methods which rely on the above, like
62 L<DBIx::Class::Relationship::Base/set_\$rel>.
63  
64 If you want full logging in a relational database, you most likely want to use this
65 component.
66  
67 =head2 NOTE:
68  
69 The current implementation enables logging in the resultset by simply delegating
70 'delete' and 'update' to 'delete_all' and 'update_all', which call the required triggers.
71 As a result, a database query like
72  
73 "DELETE FROM table WHERE id IN '1', '2', '3'"
74  
75 will result in 3 atomic queries:
76  
77 "DELETE FROM table WHERE id = '1'";
78 "DELETE FROM table WHERE id = '2'";
79 "DELETE FROM table WHERE id = '3'";
80  
81 which is much slower. It is therefore recommended to use this module only for resultset classes where it is needed.
82 Specifying this module as default resultset class is only recommended if logging is needed for all tables.
83  
84 =head1 NAME
85  
86 DBIx::Class::ResultSet::AuditLog - ResultSet base class for DBIx::Class::AuditLog
87  
88 =head1 VERSION
89  
90 version 0.1
91  
92 =head1 L<DBIx::Class::ResultSet> OVERRIDDEN METHODS
93  
94 =head2 delete
95  
96 Calls L<DBIx::Class::ResultSet/delete_all> to ensure that triggers defined by
97 L<DBIx::Class::AuditLog> are run.
98  
99 =head2 update
100  
101 Calls L<DBIx::Class::ResultSet/update_all> to ensure that triggers defined by
102 L<DBIx::Class::AuditLog> are run.
103  
104 =head1 AUTHORS
105  
106 See L<DBIx::Class::AuditLog/AUTHOR> and L<DBIx::Class::AuditLog/CONTRIBUTORS>
107  
108 =head1 COPYRIGHT AND LICENSE
109  
110 This software is copyright (c) 2012 by Mark Jubenville.
111  
112 This is free software; you can redistribute it and/or modify it under
113 the same terms as the Perl 5 programming language system itself.
114  
115 =head1 AUTHOR
116  
117 Mark Jubenville <ioncache@cpan.org>
118  
119 =head1 COPYRIGHT AND LICENSE
120  
121 This software is copyright (c) 2012 by Mark Jubenville.
122  
123 This is free software; you can redistribute it and/or modify it under
124 the same terms as the Perl 5 programming language system itself.
125  
126 =cut
« Build ↑ Summary blib/lib/DBIx/Class/Schema/AuditLog/Structure/Action.pm »