AuditAny/AuditContext/Source.pm

filter: Statementstmt 44.9% 22 / 49 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 5 / 15 Podpod 100% 2 / 2 totaltotal 39.1% 29 / 74 CC 5 SCAR 13.9
CC
5
Cov
39%
get_pri_key_value
12.0
__ANON__
6.0
_ambig_get_column
6.0
CRAP 4.0
« AuditAny/AuditContext/ChangeSet.pm ↑ Summary AuditAny/AuditContext.pm »
1 package DBIx::Class::AuditAny::AuditContext::Source;
2 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: Default 'Source' context object class for DBIx::Class::AuditAny
6  
7 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use MooX::Types::MooseLike::Base qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 extends 'DBIx::Class::AuditAny::AuditContext';
10  
11 =head1 NAME
12  
13 DBIx::Class::AuditAny::AuditContext::Source - Default 'Source' context object
14 class for DBIx::Class::AuditAny
15  
16 =head1 DESCRIPTION
17  
18 This object class represents a change to a source itself, such as its name
19  
20  
21 =head1 ATTRIBUTES
22  
23 Docs regarding the API/purpose of the attributes and methods in this class still TBD...
24  
25 =head2 ResultSource
26  
27 =head1 METHODS
28  
29 =head2 primary_columns
30  
31 =head2 get_pri_key_value
32  
33 =cut
34  
35  
36 12 has 'ResultSource', is => 'ro', required => 1;
37 21 ▶has 'source', is => 'ro', lazy => 1, default => sub { (shift)->ResultSource->source_name };
Subroutine __ANON__: called CC=1 SCAR=0.0
38 0 ▶has 'class', is => 'ro', lazy => 1, default => sub { $_[0]->SchemaObj->class($_[0]->source) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
39 0 ▶has 'from_name', is => 'ro', lazy => 1, default => sub { (shift)->ResultSource->from };
Subroutine __ANON__: not called CC=1 SCAR=1.2
40 0 ▶has 'table_name', is => 'ro', lazy => 1, default => sub { (shift)->class->table };
Subroutine __ANON__: not called CC=1 SCAR=1.2
41  
42 0 ▶sub primary_columns { return (shift)->ResultSource->primary_columns }
Subroutine primary_columns: not called CC=1 SCAR=6.9
Pod documented
43  
44 0 ▶sub _build_tiedContexts { [] }
Subroutine _build_tiedContexts: not called CC=1 SCAR=6.9
45 sub _build_local_datapoint_data {
46 0 ▶ my $self = shift;
Subroutine _build_local_datapoint_data: not called CC=1 SCAR=6.9
47 0 return { map { $_->name => $_->get_value($self) } $self->get_context_datapoints('source') };
48 }
49  
50 has 'pri_key_column', is => 'ro', isa => Maybe[Str], lazy => 1, default => sub {
51 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
52 0 my @cols = $self->primary_columns;
53 0 ▶ return undef unless (scalar(@cols) > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @cols > 0 0 0 0
54 0 my $sep = $self->primary_key_separator;
55 0 return join($sep,@cols);
56 12 };
57  
58 has 'pri_key_count', is => 'ro', isa => Int, lazy => 1, default => sub {
59 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 return scalar($self->primary_columns);
61 12 };
62  
63 sub get_pri_key_value {
64 0 ▶ my $self = shift;
Subroutine get_pri_key_value: not called CC=3 SCAR=24.8
Pod documented
65 0 my $Row = shift;
66 0 my @num = $self->pri_key_count;
67 0 ▶ return undef unless (scalar(@num) > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @num > 0 0 0 0
68 0 ▶ return $self->_ambig_get_column($Row,$self->pri_key_column) if (scalar(@num) == 1);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @num == 1 0 0 0
69 0 my $sep = $self->primary_key_separator;
70 0 return join($sep, map { $self->_ambig_get_column($Row,$_) } $self->primary_columns );
71 }
72  
73 # added as a bridge to be able to "get_column" with either a Row object
74 # or a simple HashRef via the same syntax (in get_pri_key_value above):
75 sub _ambig_get_column {
76 0 ▶ my $self = shift;
Subroutine _ambig_get_column: not called CC=2 SCAR=17.9
77 0 my $row = shift;
78 0 my $column = shift;
79 0 ▶ return ref($row) eq 'HASH' ? $row->{$column} : $row->get_column($column);
Branch: 1 branch
BranchTrueFalseTotal
ref $row eq 'HASH' ? : 0 0 0
80 }
81  
82 12 1;
83  
84 __END__
85  
86 =head1 SEE ALSO
87  
88 =over
89  
90 =item *
91  
92 L<DBIx::Class::AuditAny>
93  
94 =item *
95  
96 L<DBIx::Class>
97  
98 =back
99  
100 =head1 SUPPORT
101
102 IRC:
103
104 Join #rapidapp on irc.perl.org.
105  
106 =head1 AUTHOR
107  
108 Henry Van Styn <vanstyn@cpan.org>
109  
110 =head1 COPYRIGHT AND LICENSE
111  
112 This software is copyright (c) 2012-2015 by IntelliTree Solutions llc.
113  
114 This is free software; you can redistribute it and/or modify it under
115 the same terms as the Perl 5 programming language system itself.
116  
117 =cut
« AuditAny/AuditContext/ChangeSet.pm ↑ Summary AuditAny/AuditContext.pm »