lib/Catalyst/Model/Reaction/InterfaceModel/DBIC.pm

filter: Statementstmt 100% 45 / 45 Branchbran 50.0% 5 / 10 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 85.1% 63 / 74 CC 8 SCAR 10.0
CC
8
Cov
87%
COMPONENT
4.1
ACCEPT_CONTEXT
3.5
CONTEXTUAL_CLONE
3.0
CRAP 2.7
« lib/Reaction/UI/ViewPort/Action/Role/OK.pm ↑ Summary lib/Reaction/Test.pm »
1 package Catalyst::Model::Reaction::InterfaceModel::DBIC;
2  
3 3 ▶use Reaction::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use Catalyst::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Catalyst::Component;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Class::MOP;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #XXX so yeah, thisis kinda hacky. big whop though, i need it.
10 #this may just all together go away in the future
11  
12 3 ▶use namespace::clean -except => [ qw(meta) ];
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 extends 'Reaction::Object', 'Catalyst::Component';
14  
15  
16  
17 3 has '_schema' => (isa => 'DBIx::Class::Schema', is => 'ro', required => 1);
18 3 has '_im_class' => (is => 'ro', required => 1);
19 3 ▶sub COMPONENT {
Subroutine COMPONENT: called CC=4 SCAR=14.0
Pod documented
20 3 my ($class, $app, $args) = @_;
21 3 my %cfg = %{ Catalyst::Utils::merge_hashes($class->config, $args) };
22  
23 3 my $im_class = $cfg{im_class};
24 3 Class::MOP::load_class($im_class);
25  
26 #XXXthis could be cut out later for a more elegant method
27 3 my @domain_models = $im_class->domain_models;
28 3 ▶ confess "Unable to locate domain model in ${im_class}"
Branch: 1 branch
BranchTrueFalseTotal
if @domain_models < 1 0 3 3
29 if @domain_models < 1;
30 3 ▶ confess 'ModelBase does not yet support multiple domain models'
Branch: 1 branch
BranchTrueFalseTotal
if @domain_models > 1 0 3 3
31 if @domain_models > 1;
32 3 my $domain_model = shift @domain_models;
33 3 my $schema_class = $domain_model->_isa_metadata;
34 3 Class::MOP::load_class($schema_class);
35  
36 3 ▶ my $params = $cfg{db_params} || {};
Condition50%1/2
$cfg{'db_params'} || {}
l!l
03
MC/DC0%0/1
$cfg{'db_params'} || {}
$cfg{'db_params'}
Truth table50%1/2
A
A= $cfg{'db_params'}
Aresult
11
00
37 my $schema = $schema_class
38 3 ->connect($cfg{db_dsn}, $cfg{db_user}, $cfg{db_password}, $params);
39 3 return $class->new(_schema => $schema, _im_class => $im_class);
40 };
41 3 ▶sub ACCEPT_CONTEXT {
Subroutine ACCEPT_CONTEXT: called CC=3 SCAR=12.5
Pod documented
42 3 my ($self, $ctx) = @_;
43 3 ▶ return $self->CONTEXTUAL_CLONE($ctx) unless ref $ctx;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ctx 0 3 3
44 3 ▶ return $ctx->stash->{ref($self)} ||= $self->CONTEXTUAL_CLONE($ctx);
Condition33%1/3
$ctx->stash->{ref $self} ||= $self->CONTEXTUAL_CLONE($ctx)
l!l&&r!l&&!r
030
MC/DC0%0/2
$ctx->stash->{ref $self} ||= $self->CONTEXTUAL_CLONE($ctx)
$ctx->stash->{ref $self} $self->CONTEXTUAL_CLONE($ctx)
Truth table33%1/3
A ||= B
A= $ctx->stash->{ref $self}B= $self->CONTEXTUAL_CLONE($ctx)
ABresult
1X1
011
000
45 };
46  
47 #XXXto do build in support for RestrictByUser natively or by subclass
48 3 ▶sub CONTEXTUAL_CLONE {
Subroutine CONTEXTUAL_CLONE: called CC=3 SCAR=11.1
Pod documented
49 3 my ($self, $ctx) = @_;
50 3 my $schema = $self->_schema->clone;
51  
52 3 my $im_class = $self->_im_class;
53  
54 #XXXthis could be cut out later for a more elegant method
55 3 my @domain_models = $im_class->domain_models;
56 3 ▶ confess "Unable to locate domain model in ${im_class}"
Branch: 1 branch
BranchTrueFalseTotal
if @domain_models < 1 0 3 3
57 if @domain_models < 1;
58 3 ▶ confess 'ModelBase does not yet support multiple domain models'
Branch: 1 branch
BranchTrueFalseTotal
if @domain_models > 1 0 3 3
59 if @domain_models > 1;
60 3 my $domain_model = shift @domain_models;
61  
62 3 return $im_class->new($domain_model->name => $schema);
63 };
64  
65 3 __PACKAGE__->meta->make_immutable;
66  
67  
68  
69 3 1;
70  
71 =head1 NAME
72  
73 Catalyst::Model::Reaction::InterfaceModel::DBIC
74  
75 =head1 DESCRIPTION
76  
77 =head2 COMPONENT
78  
79 =head2 ACCEPT_CONTEXT
80  
81 =head2 CONTEXTUAL_CLONE
82  
83 =head1 CONFIG OPTIONS
84  
85 =head2 db_dsn
86  
87 =head2 db_user
88  
89 =head2 db_password
90  
91 =head2 db_params
92  
93 =head2 im_class
94  
95 =head1 AUTHORS
96  
97 See L<Reaction::Class> for authors.
98  
99 =head1 LICENSE
100  
101 See L<Reaction::Class> for the license.
102  
103 =cut
« lib/Reaction/UI/ViewPort/Action/Role/OK.pm ↑ Summary lib/Reaction/Test.pm »