File Coverage

blib/lib/DBIx/Class/AuditAny/Role/Schema.pm
Criterion Covered Total %
statement 28 30 93.3
branch 1 2 50.0
condition n/a
subroutine 12 15 80.0
pod 5 6 83.3
total 46 53 86.7


line stmt bran cond sub pod time code
1             package DBIx::Class::AuditAny::Role::Schema;
2 14     14   102 use strict;
  14         37  
  14         443  
3 14     14   76 use warnings;
  14         28  
  14         372  
4              
5             # ABSTRACT: Role to apply to tracked DBIx::Class::Schema objects
6              
7 14     14   1579 use Moo::Role;
  14         12182  
  14         179  
8 14     14   25545 use MooX::Types::MooseLike::Base qw(:all);
  14         42  
  14         5151  
9              
10              
11             =head1 NAME
12              
13             DBIx::Class::AuditAny::Role::Schema - Role to apply to tracked DBIx::Class::Schema objects
14              
15             =head1 DESCRIPTION
16              
17             This Role is for interfaces only. Its main job is to add the L<DBIx::Class::AuditAny::Role::Storage>
18             role to the DBIC storage object so the change tracking can occur.
19              
20             =head1 REQUIRES
21              
22             =head2 txn_do
23              
24             Standard method which will be available on all DBIC Schema objects
25             =cut
26              
27 14     14   133 use Try::Tiny;
  14         59  
  14         786  
28 14     14   102 use DBIx::Class::AuditAny::Util;
  14         179  
  14         1287  
29 14     14   8080 use DBIx::Class::AuditAny::Role::Storage;
  14         48  
  14         3758  
30              
31             requires 'txn_do';
32              
33             =head1 METHODS
34              
35             =head2 auditors
36              
37             =cut
38 15     15 1 368 sub auditors { (shift)->storage->auditors(@_) }
39              
40             =head2 all_auditors
41              
42             =cut
43 0     0 1 0 sub all_auditors { (shift)->storage->all_auditors(@_) }
44              
45             =head2 auditor_count
46              
47             =cut
48 15     15 1 432 sub auditor_count { (shift)->storage->auditor_count(@_) }
49              
50             =head2 add_auditor
51              
52             =cut
53 15     15 1 348 sub add_auditor { (shift)->storage->add_auditor(@_) }
54              
55             =head2 changeset_do
56              
57             =cut
58 0     0 1 0 sub changeset_do { (shift)->storage->changeset_do(@_) }
59              
60       0 0   sub BUILD {}
61             after BUILD => sub {
62             my $self = shift;
63             # Just for good measure, not usually called because the role is applied
64             # after the fact (see AuditAny.pm)
65             $self->_apply_storage_role;
66             };
67              
68             sub _apply_storage_role {
69 15     15   52 my $self = shift;
70             # Apply the role to the Storage object:
71             # Must determine driver before doing that, so that we apply
72             # the role to the correct instance ( sorry, no saner way for now )
73 15         496 $self->storage->_determine_driver;
74             Moo::Role->apply_roles_to_object($self->storage,'DBIx::Class::AuditAny::Role::Storage')
75 15 50   15   1027 unless try{$self->storage->does('DBIx::Class::AuditAny::Role::Storage')};
  15         748  
76             }
77              
78              
79             1;
80              
81              
82             __END__
83              
84             =head1 SEE ALSO
85              
86             =over
87              
88             =item *
89              
90             L<DBIx::Class::AuditAny>
91              
92             =item *
93              
94             L<DBIx::Class>
95              
96             =back
97              
98             =head1 SUPPORT
99            
100             IRC:
101            
102             Join #rapidapp on irc.perl.org.
103              
104             =head1 AUTHOR
105              
106             Henry Van Styn <vanstyn@cpan.org>
107              
108             =head1 COPYRIGHT AND LICENSE
109              
110             This software is copyright (c) 2012-2015 by IntelliTree Solutions llc.
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             =cut