File Coverage

blib/lib/DBIx/Class/AuditAny/Util/BuiltinDatapoints.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 1 1 100.0
total 30 30 100.0


line stmt bran cond sub pod time code
1             package # Hide from PAUSE
2             DBIx::Class::AuditAny::Util::BuiltinDatapoints;
3              
4             # ABSTRACT: Built-in datapoint configs for DBIx::Class::AuditAny
5              
6             =head1 NAME
7              
8             DBIx::Class::AuditAny::Util::BuiltinDatapoints - Built-in datapoint configs for DBIx::Class::AuditAny
9              
10             =head1 DESCRIPTION
11              
12             These are just lists of predefined hashref configs ($cnf) - DataPoint constructor arg
13             i.e. my $DataPoint = DBIx::Class::AuditAny::DataPoint->new(%$cnf);
14              
15             This module is used internally and should not need to be called directly
16              
17             =head1 METHODS
18              
19             =cut
20              
21 13     13   454599 use strict;
  13         19  
  13         344  
22 13     13   45 use warnings;
  13         17  
  13         4863  
23              
24              
25             =head2 all_configs
26              
27             Return all the builtin configs
28              
29             =cut
30             sub all_configs {(
31 15     15 1 115 &_base_context,
32             &_source_context,
33             &_set_context,
34             &_change_context,
35             &_column_context,
36             )}
37              
38              
39             sub _base_context {
40 30         151 map {{ context => 'base', %$_ }} (
41             {
42             name => 'schema',
43 6     6   88 method => sub { ref((shift)->AuditObj->schema) },
44             column_info => { data_type => "varchar", is_nullable => 0, size => 255 }
45             },
46             {
47             name => 'schema_ver',
48 6     6   180 method => sub { (shift)->AuditObj->schema->schema_version },
49 15     15   221 column_info => { data_type => "varchar", is_nullable => 1, size => 16 }
50             }
51             )
52             }
53              
54             # set 'method' as a direct passthrough to $Context->'name' per default (see DataPoint class)
55             sub _source_context {
56 15     15   239 map {{ context => 'source', method => $_->{name}, %$_ }} (
  90         266  
57             {
58             name => 'source',
59             column_info => { data_type => "varchar", is_nullable => 0, size => 255 }
60             },
61             {
62             name => 'class',
63             column_info => { data_type => "varchar", is_nullable => 0, size => 255 }
64             },
65             {
66             name => 'from_name',
67             column_info => { data_type => "varchar", is_nullable => 0, size => 128 }
68             },
69             {
70             name => 'table_name',
71             column_info => { data_type => "varchar", is_nullable => 0, size => 128 }
72             },
73             {
74             name => 'pri_key_column',
75             column_info => { data_type => "varchar", is_nullable => 0, size => 64 }
76             },
77             {
78             name => 'pri_key_count',
79             column_info => { data_type => "integer", extra => { unsigned => 1 }, is_nullable => 0 }
80             }
81             )
82             }
83              
84             # set 'method' as a direct passthrough to $Context->'name' per default (see DataPoint class)
85             sub _set_context {
86 15     15   135 map {{ context => 'set', method => $_->{name}, %$_ }} (
  45         160  
87             {
88             name => 'changeset_ts',
89             column_info => {
90             data_type => "datetime",
91             datetime_undef_if_invalid => 1,
92             is_nullable => 0
93             }
94             },
95             {
96             name => 'changeset_finish_ts',
97             column_info => {
98             data_type => "datetime",
99             datetime_undef_if_invalid => 1,
100             is_nullable => 0
101             }
102             },
103             {
104             name => 'changeset_elapsed',
105             column_info => { data_type => "varchar", is_nullable => 0, size => 16 }
106             },
107             )
108             }
109              
110             # set 'method' as a direct passthrough to $Context->'name' per default (see DataPoint class)
111             sub _change_context {
112 15     15   334 map {{ context => 'change', method => $_->{name}, %$_ }} (
  120         319  
113             {
114             name => 'change_ts',
115             column_info => {
116             data_type => "datetime",
117             datetime_undef_if_invalid => 1,
118             is_nullable => 0
119             }
120             },
121             {
122             name => 'action',
123             column_info => { data_type => "char", is_nullable => 0, size => 6 }
124             },
125             {
126             name => 'action_id',
127             column_info => { data_type => "integer", is_nullable => 0 }
128             },
129             {
130             name => 'pri_key_value',
131             column_info => { data_type => "varchar", is_nullable => 0, size => 255 }
132             },
133             {
134             name => 'orig_pri_key_value',
135             column_info => { data_type => "varchar", is_nullable => 0, size => 255 }
136             },
137             {
138             name => 'change_elapsed',
139             column_info => { data_type => "varchar", is_nullable => 0, size => 16 }
140             },
141             {
142             name => 'column_changes_json',
143             column_info => { data_type => "mediumtext", is_nullable => 1 }
144             },
145             {
146             name => 'column_changes_ascii',
147             column_info => { data_type => "mediumtext", is_nullable => 1 }
148             },
149             )
150             }
151              
152             # set 'method' as a direct passthrough to $Context->'name' per default (see DataPoint class)
153             sub _column_context {
154 15     15   122 map {{ context => 'column', method => $_->{name}, %$_ }} (
  45         262  
155             {
156             name => 'column_name',
157             column_info => { data_type => "varchar", is_nullable => 0, size => 128 }
158             },
159             {
160             name => 'old_value',
161             column_info => { data_type => "mediumtext", is_nullable => 1 }
162             },
163             {
164             name => 'new_value',
165             column_info => { data_type => "mediumtext", is_nullable => 1 }
166             },
167            
168             # TODO: add 'diff' datapoint
169            
170             )
171             }
172              
173              
174             1;
175              
176             __END__
177              
178             =head1 SEE ALSO
179              
180             =over
181              
182             =item *
183              
184             L<DBIx::Class::AuditAny>
185              
186             =item *
187              
188             L<DBIx::Class>
189              
190             =back
191              
192             =head1 SUPPORT
193            
194             IRC:
195            
196             Join #rapidapp on irc.perl.org.
197              
198             =head1 AUTHOR
199              
200             Henry Van Styn <vanstyn@cpan.org>
201              
202             =head1 COPYRIGHT AND LICENSE
203              
204             This software is copyright (c) 2012-2015 by IntelliTree Solutions llc.
205              
206             This is free software; you can redistribute it and/or modify it under
207             the same terms as the Perl 5 programming language system itself.
208              
209             =cut