Factory/Processor/Role.pm

filter: Statementstmt 75.0% 27 / 36 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 61.5% 8 / 13 Podpod 100% 8 / 8 totaltotal 72.1% 44 / 61 CC 3 SCAR 7.3
CC
3
Cov
70%
use_feature
6.0
_add_function
2.0
deferred_value
2.0
CRAP 2.1
« Factory/Feature/Control/MatchCode.pm ↑ Summary Factory/Result/Single.pm »
1 package Form::Factory::Processor::Role;
2 1 $Form::Factory::Processor::Role::VERSION = '0.022';
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Form::Factory::Action::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 Moose::Exporter->setup_import_methods(
10 as_is => [ qw( deferred_value ) ],
11 with_meta => [ qw(
12 has_control use_feature
13 has_cleaner has_checker has_pre_processor has_post_processor
14 ) ],
15 also => 'Moose::Role',
16 );
17  
18 # ABSTRACT: Moos-ish helper for action roles
19  
20  
21 2 ▶sub init_meta {
Subroutine init_meta: called CC=1 SCAR=0.0
Pod documented
22 2 my $package = shift;
23 2 my %options = @_;
24  
25 2 Moose::Role->init_meta(%options);
26  
27 my $meta = Moose::Util::MetaRole::apply_metaroles(
28 for => $options{for_class},
29 2 role_metaroles => {
30 role => [ 'Form::Factory::Action::Meta::Role' ],
31 },
32 );
33  
34 Moose::Util::apply_all_roles(
35 2 $options{for_class}, 'Form::Factory::Action::Role',
36 );
37  
38 2 return $meta;
39 }
40  
41  
42 2 ▶sub has_control {
Subroutine has_control: called CC=1 SCAR=0.0
Pod documented
43 2 my ($meta, $name, $args) = Form::Factory::Processor::_setup_control_defaults(@_);
44 2 $meta->add_attribute( $name => %$args );
45 }
46  
47  
48 0 ▶sub use_feature {
Subroutine use_feature: not called CC=2 SCAR=17.9
Pod documented
49 0 my $meta = shift;
50 0 my $name = shift;
51 0 ▶ my $args = @_ == 1 ? shift : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 0 0
52  
53 0 $meta->features->{$name} = $args;
54 }
55  
56  
57 0 ▶sub deferred_value(&) {
Subroutine deferred_value: not called CC=1 SCAR=6.9
Pod documented
58 0 my $code = shift;
59  
60 0 return Form::Factory::Processor::DeferredValue->new(
61 code => $code,
62 );
63 }
64  
65  
66 2 ▶sub _add_function {
Subroutine _add_function: called CC=2 SCAR=7.1
67 2 my ($type, $meta, $name, $code) = @_;
68 2 ▶ Carp::croak("bad code given for $type $name") unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 2 2
69 2 $meta->features->{functional}{$type . '_code'}{$name} = $code;
70 }
71  
72 2 ▶sub has_cleaner { _add_function('cleaner', @_) }
Subroutine has_cleaner: called CC=1 SCAR=0.0
Pod documented
73 0 ▶sub has_checker { _add_function('checker', @_) }
Subroutine has_checker: not called CC=1 SCAR=6.9
Pod documented
74 0 ▶sub has_pre_processor { _add_function('pre_processor', @_) }
Subroutine has_pre_processor: not called CC=1 SCAR=6.9
Pod documented
75 0 ▶sub has_post_processor { _add_function('post_processor', @_) }
Subroutine has_post_processor: not called CC=1 SCAR=6.9
Pod documented
76  
77  
78 1 __PACKAGE__->meta->make_immutable;
79  
80 __END__
« Factory/Feature/Control/MatchCode.pm ↑ Summary Factory/Result/Single.pm »