File Coverage

blib/lib/DBIx/Class/AuditAny/AuditContext.pm
Criterion Covered Total %
statement 28 32 87.5
branch 3 4 75.0
condition n/a
subroutine 11 14 78.5
pod 8 8 100.0
total 50 58 86.2


line stmt bran cond sub pod time code
1             package # Hide from PAUSE
2             DBIx::Class::AuditAny::AuditContext;
3 13     13   5952 use strict;
  13         20  
  13         322  
4 13     13   47 use warnings;
  13         18  
  13         302  
5              
6             # ABSTRACT: Base class for context objects in DBIx::Class::AuditAny
7              
8 13     13   45 use Moo;
  13         13  
  13         61  
9 13     13   15951 use MooX::Types::MooseLike::Base qw(:all);
  13         20  
  13         7484  
10              
11             =head1 NAME
12              
13             DBIx::Class::AuditAny::AuditContext - Base class for context objects in DBIx::Class::AuditAny
14              
15             =head1 DESCRIPTION
16              
17             This class is used internally and typically does not need to be called directly
18              
19             =head1 ATTRIBUTES
20              
21             =head2 AuditObj
22              
23             Required. Reference to the Auditor object (L<DBIx::Class::AuditAny>).
24              
25             =cut
26             has 'AuditObj', is => 'ro', isa => InstanceOf['DBIx::Class::AuditAny'], required => 1;
27              
28             =head2 tiedContexts
29              
30             Used internally
31              
32             =cut
33             has 'tiedContexts', is => 'lazy', isa => ArrayRef[Object];#, lazy_build => 1;
34              
35             =head2 local_datapoint_data
36              
37             Used internally
38              
39             =cut
40             has 'local_datapoint_data', is => 'lazy', isa => HashRef;#, lazy_build => 1;
41              
42 0     0   0 sub _build_tiedContexts { die "Virtual method" }
43 0     0   0 sub _build_local_datapoint_data { die "Virtual method" }
44              
45              
46             =head1 METHODS
47              
48             =head2 get_datapoint_value
49              
50             =cut
51             sub get_datapoint_value {
52 1282     1282 1 1081 my $self = shift;
53 1282         1107 my $name = shift;
54 1282         1050 my @Contexts = ($self,@{$self->tiedContexts},$self->AuditObj);
  1282         17365  
55 1282         23951 foreach my $Context (@Contexts) {
56             return $Context->local_datapoint_data->{$name}
57 1538 100       26941 if (exists $Context->local_datapoint_data->{$name});
58             }
59 0         0 die "Unknown datapoint '$name'";
60             }
61              
62             =head2 get_datapoints_data
63              
64             =cut
65             sub get_datapoints_data {
66 369     369 1 2075 my $self = shift;
67 369 50       792 my @names = (ref($_[0]) eq 'ARRAY') ? @{ $_[0] } : @_; # <-- arg as array or arrayref
  369         852  
68 369         447 return { map { $_ => $self->get_datapoint_value($_) } @names };
  1282         25362  
69             }
70              
71              
72             =head2 SchemaObj
73              
74             =cut
75 1     1 1 21 sub SchemaObj { (shift)->AuditObj->schema };
76              
77              
78             =head2 schema
79              
80             =cut
81 0     0 1 0 sub schema { ref (shift)->AuditObj->schema };
82              
83              
84             =head2 primary_key_separator
85              
86             =cut
87 25     25 1 143 sub primary_key_separator { (shift)->AuditObj->primary_key_separator };
88              
89              
90             =head2 get_context_datapoints
91              
92             =cut
93 393     393 1 1199 sub get_context_datapoints { (shift)->AuditObj->get_context_datapoints(@_) };
94              
95              
96             =head2 get_context_datapoint_names
97              
98             =cut
99 3     3 1 14 sub get_context_datapoint_names { (shift)->AuditObj->get_context_datapoint_names(@_) };
100              
101              
102             =head2 get_dt
103              
104             =cut
105 186     186 1 948 sub get_dt { (shift)->AuditObj->get_dt(@_) };
106              
107             1;
108              
109             __END__
110              
111             =head1 SEE ALSO
112              
113             =over
114              
115             =item *
116              
117             L<DBIx::Class::AuditAny>
118              
119             =item *
120              
121             L<DBIx::Class>
122              
123             =back
124              
125             =head1 SUPPORT
126            
127             IRC:
128            
129             Join #rapidapp on irc.perl.org.
130              
131             =head1 AUTHOR
132              
133             Henry Van Styn <vanstyn@cpan.org>
134              
135             =head1 COPYRIGHT AND LICENSE
136              
137             This software is copyright (c) 2012-2015 by IntelliTree Solutions llc.
138              
139             This is free software; you can redistribute it and/or modify it under
140             the same terms as the Perl 5 programming language system itself.
141              
142             =cut