| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 45 | 0 | my $instruction = $self->get_item_by_type($type); | |||||||||
| 46 | 0 | ▶ | next unless defined $instruction; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | $object->$field($instruction->value); | |||||||||
| 48 | } | ||||||||||
| 49 | } | ||||||||||
| 50 | 1 | 1; | |||||||||
| 51 | |||||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||