Conveyor/Ticket/Payload/Instruction/Container.pm

filter: Statementstmt 43.3% 13 / 30 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 5 / 10 Podpod 100% 5 / 5 totaltotal 43.4% 23 / 53 CC 7 SCAR 18.6
CC
7
Cov
34%
get_item_by_type
12.0
apply_fields_to_object
12.0
check
6.0
CRAP 6.4
« Conveyor/App/Test/Stage/Integration.pm ↑ Summary Conveyor/App/Mutex.pm »
1 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Conveyor::Ticket::Payload::Instruction::Container;
6 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $Data::Conveyor::Ticket::Payload::Instruction::Container::VERSION = '1.103130';
8 }
9 # ABSTRACT: Stage-based conveyor-belt-like ticket handling system
10  
11 # ptags: DCTPIC
12 1 ▶use parent qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
13 Data::Container
14 Class::Scaffold::Storable
15 1 );
16  
17 # Override stringification to return an unblessed copy of the object's hash
18 # because our items don't stringify well.
19 0 ▶sub stringify { +{%{$_[0]}} }
Subroutine stringify: not called CC=1 SCAR=6.9
Pod documented
20  
21 0 ▶sub check {
Subroutine check: not called CC=2 SCAR=17.9
Pod documented
22 0 my ($self, $exception_container, $ticket) = @_;
23 0 $_->check($exception_container, $ticket) for $self->items;
24 }
25  
26 0 ▶sub get_item_by_type {
Subroutine get_item_by_type: not called CC=3 SCAR=24.8
Pod documented
27 0 my ($self, $type) = @_;
28 0 for my $instruction ($self->items) {
29 0 ▶ return $instruction if $instruction->type eq $type;
Branch: 1 branch
BranchTrueFalseTotal
if $instruction->type eq $type 0 0 0
30 }
31 0 undef;
32 }
33  
34 # apply_fields_to_object() only handles single values; if you expect a list,
35 # use this method and apply the instructions yourself.
36 0 ▶sub get_items_of_type {
Subroutine get_items_of_type: not called CC=2 SCAR=17.9
Pod documented
37 0 my ($self, $type) = @_;
38 0 my @retval = grep { $_->type eq $type } $self->items;
39 0 ▶ wantarray ? @retval : \@retval;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
40 }
41  
42 0 ▶sub apply_fields_to_object {
Subroutine apply_fields_to_object: not called CC=3 SCAR=24.8
Pod documented
43 0 my ($self, $object, %field_map) = @_;
44 0 ▶ while (my ($type, $field) = each %field_map) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %field_map) 0 0 0
45 0 my $instruction = $self->get_item_by_type($type);
46 0 ▶ next unless defined $instruction;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $instruction 0 0 0
47 0 $object->$field($instruction->value);
48 }
49 }
50 1 1;
51  
52  
53 __END__
« Conveyor/App/Test/Stage/Integration.pm ↑ Summary Conveyor/App/Mutex.pm »