lib/Mojolicious/Plugin/Fondation/Group.pm

filter: Statementstmt 76.4% 13 / 17 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 33.3% 1 / 3 totaltotal 74.0% 20 / 27 CC 2 SCAR 4.5
CC
2
Cov
74%
fondation_finalyze
2.7
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« blib/lib/Mojolicious/Plugin/Fondation/Group/Controller/Group.pm ↑ Summary lib/Mojolicious/Plugin/Fondation/Group/Schema/Result/Group.pm »
1 package Mojolicious::Plugin::Fondation::Group;
2 1 $Mojolicious::Plugin::Fondation::Group::VERSION = '0.03';
3 1 ▶use Mojo::Base 'Mojolicious::Plugin', -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use DBIx::Class::Relationship::ManyToMany::Async;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: Group management plugin for Fondation
7  
8 1 ▶sub fondation_meta {
Subroutine fondation_meta: called CC=1 SCAR=0.0
Pod undocumented
9 return {
10 1 dependencies => [
11 'Fondation::Model::DBIx::Async',
12 'Fondation::MigrationDBIx',
13 ],
14 defaults => {
15 title => 'Group Management',
16 openapi_exclude => ['UserGroup'],
17 models => {
18 group => {
19 source => 'Group',
20 backend => undef, # must be set in app config
21 },
22 user_group => {
23 source => 'UserGroup',
24 backend => undef, # must be set in app config
25 },
26 },
27 },
28 };
29 }
30  
31 1 ▶sub register ($self, $app, $conf) {
Subroutine register: called CC=1 SCAR=0.0
Pod documented
32 1 return $self;
33 }
34  
35 1 ▶sub fondation_finalyze ($self, $app, $long_name) {
Subroutine fondation_finalyze: called CC=2 SCAR=9.9
Pod undocumented
36 1 my $registry = $app->fondation->registry;
37  
38 # Only establish user↔group relation if User plugin is loaded
39 1 ▶ if ($registry->{'Mojolicious::Plugin::Fondation::User'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($registry->{"Mojolicious::Plugin::Fondation::User"}) 0 1 1
40 # Underlying has_many / belongs_to
41 0 Mojolicious::Plugin::Fondation::User::Schema::Result::User->has_many(
42 'user_group',
43 'Mojolicious::Plugin::Fondation::Group::Schema::Result::UserGroup',
44 'user_id',
45 );
46 0 Mojolicious::Plugin::Fondation::Group::Schema::Result::UserGroup->belongs_to(
47 'user',
48 'Mojolicious::Plugin::Fondation::User::Schema::Result::User',
49 { 'foreign.id' => 'self.user_id' },
50 );
51  
52 0 many_to_many_async('Mojolicious::Plugin::Fondation::User::Schema::Result::User', 'groups', 'user_group', 'group');
53 0 many_to_many_async('Mojolicious::Plugin::Fondation::Group::Schema::Result::Group', 'users', 'user_group', 'user');
54 }
55  
56 1 return 1;
57 }
58  
59 1 1;
60  
61 __END__
« blib/lib/Mojolicious/Plugin/Fondation/Group/Controller/Group.pm ↑ Summary lib/Mojolicious/Plugin/Fondation/Group/Schema/Result/Group.pm »