| 1 | package DBIx::Class::AuditAny::Role::Schema; | ||||||||||
| 2 | 14 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 14 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | # ABSTRACT: Role to apply to tracked DBIx::Class::Schema objects | ||||||||||
| 6 | |||||||||||
| 7 | 14 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 14 | ▶ | use MooX::Types::MooseLike::Base qw(:all); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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 | ▶ | use Try::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 14 | ▶ | use DBIx::Class::AuditAny::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 14 | ▶ | use DBIx::Class::AuditAny::Role::Storage; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | |||||||||||
| 31 | 14 | requires 'txn_do'; | |||||||||
| 32 | |||||||||||
| 33 | =head1 METHODS | ||||||||||
| 34 | |||||||||||
| 35 | =head2 auditors | ||||||||||
| 36 | |||||||||||
| 37 | =cut | ||||||||||
| 38 | 17 | ▶ | sub auditors { (shift)->storage->auditors(@_) } | ||||||||
|
Subroutine
auditors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | |||||||||||
| 40 | =head2 all_auditors | ||||||||||
| 41 | |||||||||||
| 42 | =cut | ||||||||||
| 43 | 0 | ▶ | sub all_auditors { (shift)->storage->all_auditors(@_) } | ||||||||
|
Subroutine
all_auditors: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 44 | |||||||||||
| 45 | =head2 auditor_count | ||||||||||
| 46 | |||||||||||
| 47 | =cut | ||||||||||
| 48 | 17 | ▶ | sub auditor_count { (shift)->storage->auditor_count(@_) } | ||||||||
|
Subroutine
auditor_count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 49 | |||||||||||
| 50 | =head2 add_auditor | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | 17 | ▶ | sub add_auditor { (shift)->storage->add_auditor(@_) } | ||||||||
|
Subroutine
add_auditor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 54 | |||||||||||
| 55 | =head2 changeset_do | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||
| 58 | 0 | ▶ | sub changeset_do { (shift)->storage->changeset_do(@_) } | ||||||||
|
Subroutine
changeset_do: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub BUILD {} | ||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 61 | 0 | ▶ | after BUILD => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 62 | 0 | my $self = shift; | |||||||||
| 63 | # Just for good measure, not usually called because the role is applied | ||||||||||
| 64 | # after the fact (see AuditAny.pm) | ||||||||||
| 65 | 0 | $self->_apply_storage_role; | |||||||||
| 66 | 14 | }; | |||||||||
| 67 | |||||||||||
| 68 | 17 | ▶ | sub _apply_storage_role { | ||||||||
|
Subroutine
_apply_storage_role: called CC=2 SCAR=7.0
| |||||||||||
| 69 | 17 | 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 | 17 | $self->storage->_determine_driver; | |||||||||
| 74 | Moo::Role->apply_roles_to_object($self->storage,'DBIx::Class::AuditAny::Role::Storage') | ||||||||||
| 75 | 17 | ▶ | unless try{$self->storage->does('DBIx::Class::AuditAny::Role::Storage')}; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | |||||||||||
| 79 | 14 | 1; | |||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | __END__ | ||||||||||