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 13     13   47 use strict;
  13         16  
  13         311  
3 13     13   46 use warnings;
  13         13  
  13         271  
4              
5             # ABSTRACT: Role to apply to tracked DBIx::Class::Schema objects
6              
7 13     13   1556 use Moo::Role;
  13         9136  
  13         110  
8 13     13   18082 use MooX::Types::MooseLike::Base qw(:all);
  13         16  
  13         4085  
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 13     13   61 use Try::Tiny;
  13         15  
  13         691  
28 13     13   52 use DBIx::Class::AuditAny::Util;
  13         15  
  13         894  
29 13     13   6007 use DBIx::Class::AuditAny::Role::Storage;
  13         35  
  13         2822  
30              
31             requires 'txn_do';
32              
33             =head1 METHODS
34              
35             =head2 auditors
36              
37             =cut
38 14     14 1 608 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 14     14 1 363 sub auditor_count { (shift)->storage->auditor_count(@_) }
49              
50             =head2 add_auditor
51              
52             =cut
53 14     14 1 230 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 14     14   33 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 14         416 $self->storage->_determine_driver;
74             Moo::Role->apply_roles_to_object($self->storage,'DBIx::Class::AuditAny::Role::Storage')
75 14 50   14   734 unless try{$self->storage->does('DBIx::Class::AuditAny::Role::Storage')};
  14         497  
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