blib/lib/OpusVL/AppKit/RolesFor/Schema/DataInitialisation.pm

filter: Statementstmt 22.2% 4 / 18 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 1 / 4 Podpod 66.6% 2 / 3 totaltotal 22.5% 7 / 31 CC 6 SCAR 25.8
CC
6
Cov
17%
initdb
20.0
clear_dataset
12.0
deploy_with_data
2.0
CRAP 13.2
« lib/OpusVL/AppKit/Controller/AppKit/Admin/Access.pm ↑ Summary blib/lib/OpusVL/AppKit/Plugin/AppKit.pm »
1 package OpusVL::AppKit::RolesFor::Schema::DataInitialisation;
2  
3 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 sub deploy_with_data
6 {
7 0 ▶ my $self = shift;
Subroutine deploy_with_data: not called CC=1 SCAR=6.9
Pod documented
8 0 $self->deploy;
9 0 $self->initdb;
10 0 return $self;
11 }
12  
13 sub initdb
14 {
15 0 ▶ my $self = shift;
Subroutine initdb: not called CC=4 SCAR=30.0
Pod undocumented
16 0 for my $resultset ($self->sources)
17 {
18 0 my $rs = $self->resultset($resultset);
19 0 ▶ $rs->initdb if $rs->can('initdb');
Branch: 1 branch
BranchTrueFalseTotal
if $rs->can("initdb") 0 0 0
20 0 ▶ $rs->initdb_populate if $rs->can('initdb_populate');
Branch: 1 branch
BranchTrueFalseTotal
if $rs->can("initdb_populate") 0 0 0
21 }
22 }
23  
24 sub clear_dataset
25 {
26 0 ▶ my $self = shift;
Subroutine clear_dataset: not called CC=3 SCAR=24.8
Pod documented
27 0 for my $resultset ($self->sources)
28 {
29 0 my $rs = $self->resultset($resultset);
30 0 ▶ $rs->clear_dataset if $rs->can('clear_dataset');
Branch: 1 branch
BranchTrueFalseTotal
if $rs->can("clear_dataset") 0 0 0
31 }
32 0 return $self;
33 }
34  
35 1 1;
36  
37 __END__
38  
39 =pod
40  
41 =encoding UTF-8
42  
43 =head1 NAME
44  
45 OpusVL::AppKit::RolesFor::Schema::DataInitialisation
46  
47 =head1 VERSION
48  
49 version 2.24
50  
51 =head1 DESCRIPTION
52  
53 This role allows you to extend your DBIx::Class::Schema with a deploy_with_data
54 method that can be used instead of deploy to deploy and populate your database
55 with some initial data. This is typically used to put a basic user into an auth
56 database and setting up any standard system parameters that are required.
57  
58 package My::Schema;
59 use Moose;
60 use namespace::autoclean;
61 extends 'DBIx::Class::Schema';
62 with 'OpusVL::AppKit::RolesFor::Schema::DataInitialisation';
63 __PACKAGE__->load_namespaces;
64 __PACKAGE__->meta->make_immutable;
65 1;
66  
67 =head1 NAME
68  
69 OpusVL::AppKit::RolesFor::Schema::DataInitialisation - Deploy with data
70  
71 =head1 METHODS
72  
73 =head2 deploy_with_data
74  
75 This method does a deploy and then checks your resultsets for initdb methods to call.
76 If they are found they are called. This allows you to populate your newly deployed
77 database with initial data.
78  
79 =head2 clear_dataset
80  
81 A method to call clear_dataset on all the resultsets that support the method. The
82 idea is to allow a method for clearing a dataset of all transient data while
83 retaining all essential configuration. This will vary by project and so is down
84 to how you implement it.
85  
86 =head1 LICENSE AND COPYRIGHT
87  
88 Copyright 2012 OpusVL.
89  
90 This software is licensed according to the "IP Assignment Schedule" provided with the development project.
91  
92 =head1 AUTHOR
93  
94 OpusVL - www.opusvl.com
95  
96 =head1 COPYRIGHT AND LICENSE
97  
98 This software is copyright (c) 2010 by OpusVL - www.opusvl.com.
99  
100 This is free software; you can redistribute it and/or modify it under
101 the same terms as the Perl 5 programming language system itself.
102  
103 =cut
« lib/OpusVL/AppKit/Controller/AppKit/Admin/Access.pm ↑ Summary blib/lib/OpusVL/AppKit/Plugin/AppKit.pm »