RoutesAuthDBI/Model/Profiles.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 42 CC 5 SCAR 18.9
CC
5
Cov
0%
get_profile
12.0
profiles
6.0
new_profile
6.0
CRAP 6.6
1 package Profile;
2 use Mojo::Base -base;
3  
4 has [qw(roles auth_cookie)];
5  
6 #==========
7 # END Profie pkg
8 #==========
9  
10 package Mojolicious::Plugin::RoutesAuthDBI::Model::Profiles;
11 #~ use Mojo::Base 'DBIx::Mojo::Model';
12 use Mojo::Base 'Mojolicious::Plugin::RoutesAuthDBI::Model::Base';
13  
14  
15 #~ has roles => sub {
16 #~ my $self=shift;
17 #~ $self->dbh->selectall_arrayref($self->sth('profile roles'), { Slice => {} }, ($self->{id}));
18
19 #~ };
20  
21 #~ sub new {
22 #~ state $self = shift->SUPER::new(@_);
23 #~ }
24  
25 sub get_profile {
26 my $self = ref($_[0]) ? shift : shift->new;
27 my $p = $self->dbh->selectrow_hashref($self->sth('profile'), undef, (shift, shift,));
28 #~ bless($p)->SUPER::new# reinit from singleton dict Это работало, но большая портянка объекта модели
29 return bless($p, "Profile")->roles($self->roles($p->{id}))#->model($self)
30 if $p && $p->{id};
31 return undef;
32 }
33  
34 sub roles {
35 my ($self, $profile_id) = @_;
36 $self->dbh->selectall_arrayref($self->sth('profile roles'), { Slice => {} }, ($profile_id));
37
38 };
39  
40 sub profiles {
41 my $self = ref($_[0]) ? shift : shift->new;
42 $self->dbh->selectall_arrayref($self->sth('profiles'), {Slice=>{}},);
43 }
44  
45 sub new_profile {
46 my $self = ref($_[0]) ? shift : shift->new;
47
48 $self->dbh->selectrow_hashref($self->sth('new profile'), undef, (shift,));
49 }
50  
51 1;
52  
53 __DATA__