lib/Reaction/InterfaceModel/Object.pm

filter: Statementstmt 97.4% 38 / 39 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 100% 3 / 3 totaltotal 92.5% 62 / 67 CC 7 SCAR 6.4
CC
7
Cov
90%
_action_class_for
3.3
_default_action_class_for
3.0
action_for
2.0
CRAP 1.9
« lib/Reaction/UI/Controller/Role/Action/Update.pm ↑ Summary lib/Reaction/UI/ViewPort/Action.pm »
1 package Reaction::InterfaceModel::Object;
2  
3 6 ▶use metaclass 'Reaction::Meta::InterfaceModel::Object::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use Reaction::Meta::Attribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Reaction::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use namespace::clean -except => [ qw(meta) ];
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 has _action_class_map =>
11 121 ▶ (is => 'rw', isa => 'HashRef', required => 1, default => sub{ {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
12 6 metaclass => 'Reaction::Meta::Attribute');
13  
14 6 has _default_action_class_prefix =>
15 (
16 is => 'ro',
17 isa => 'Str',
18 lazy_build => 1,
19 metaclass => 'Reaction::Meta::Attribute',
20 );
21  
22 #DBIC::Collection would override this to use result_class for example
23 66 ▶sub _build__default_action_class_prefix {
Subroutine _build__default_action_class_prefix: called CC=2 SCAR=6.9
24 66 my $self = shift;
25 66 ▶ ref $self || $self;
Branch: 1 branch
BranchTrueFalseTotal
ref $self or $self 6 60 66
26 };
27  
28 #just a little convenience
29 64 ▶sub parameter_attributes {
Subroutine parameter_attributes: called CC=1 SCAR=0.0
Pod documented
30 64 shift->meta->parameter_attributes;
31 };
32  
33 #just a little convenience
34 10 ▶sub domain_models {
Subroutine domain_models: called CC=1 SCAR=0.0
Pod documented
35 10 shift->meta->domain_models;
36 };
37 75 ▶sub _default_action_class_for {
Subroutine _default_action_class_for: called CC=3 SCAR=11.0
38 75 my ($self, $action) = @_;
39 75 ▶ confess("Wrong arguments") unless $action;
Branch: 1 branch
BranchTrueFalseTotal
unless $action 0 75 75
40 #little trick in case we call it in class context!
41 75 ▶ my $prefix = ref $self ?
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 15 60 75
42 $self->_default_action_class_prefix :
43 $self->_build__default_action_class_prefix;
44  
45 75 return join "::", $prefix, 'Action', $action;
46 };
47 15 ▶sub _action_class_for {
Subroutine _action_class_for: called CC=3 SCAR=12.0
48 15 my ($self, $action) = @_;
49 15 ▶ confess("Wrong arguments") unless $action;
Branch: 1 branch
BranchTrueFalseTotal
unless $action 0 15 15
50 15 ▶ if (defined (my $class = $self->_action_class_map->{$action})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $class = $self->_action_class_map->{$action})) 0 15 15
51 0 return $class;
52 }
53 15 return $self->_default_action_class_for($action);
54 };
55 15 ▶sub action_for {
Subroutine action_for: called CC=2 SCAR=7.0
Pod documented
56 15 my ($self, $action, %args) = @_;
57 15 ▶ confess("Wrong arguments") unless $action;
Branch: 1 branch
BranchTrueFalseTotal
unless $action 0 15 15
58 15 my $class = $self->_action_class_for($action);
59 %args = (
60 15 %{$self->_default_action_args_for($action)},
61 %args,
62 15 %{$self->_override_action_args_for($action)},
63 );
64 15 return $class->new(%args);
65 };
66  
67 #this really needs to be smarter, fine for CRUD, shit for anything else
68 # massive fucking reworking needed here, really
69 15 ▶sub _default_action_args_for { {} };
Subroutine _default_action_args_for: called CC=1 SCAR=0.0
70 15 ▶sub _override_action_args_for { {} };
Subroutine _override_action_args_for: called CC=1 SCAR=0.0
71  
72 6 __PACKAGE__->meta->make_immutable;
73  
74  
75 6 1;
76  
77 __END__;
« lib/Reaction/UI/Controller/Role/Action/Update.pm ↑ Summary lib/Reaction/UI/ViewPort/Action.pm »