| 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::Stage::TxSelector; | ||||||||||||||||||||
| 6 | 1 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | $Data::Conveyor::Stage::TxSelector::VERSION = '1.103130'; | |||||||||||||||||||
| 8 | } | ||||||||||||||||||||
| 9 | # ABSTRACT: Stage-based conveyor-belt-like ticket handling system | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | # Implements the transaction selector (txsel) | ||||||||||||||||||||
| 12 | 1 | ▶ | use Error::Hierarchy::Util 'assert_defined'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use parent 'Data::Conveyor::Stage::SingleTicket'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 0 | ▶ | sub DEFAULTS { | ||||||||||||||||||
|
Subroutine
DEFAULTS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 16 | 0 | (expected_stage => $_[0]->delegate->ST_TXSEL); | |||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | # Return a list of object types that specifies in which order payload items | ||||||||||||||||||||
| 20 | # should be traversed. Subclasses might need to override this with a specific | ||||||||||||||||||||
| 21 | # order, for example, when new payload items are created implicitly. | ||||||||||||||||||||
| 22 | # | ||||||||||||||||||||
| 23 | # don't include transaction itself in calculating transactions | ||||||||||||||||||||
| 24 | 0 | ▶ | sub object_type_iteration_order { | ||||||||||||||||||
|
Subroutine
object_type_iteration_order: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 25 | 0 | grep { $_ ne $_[0]->delegate->OT_TRANSACTION } $_[0]->delegate->OT; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub main { | ||||||||||||||||||
|
Subroutine
main: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 29 | 0 | my ($self, %args) = @_; | |||||||||||||||||||
| 30 | 0 | $self->SUPER::main(%args); | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | # Txsel handlers can create implicit payload items; to ensure idempotency, | ||||||||||||||||||||
| 33 | # we remove them before reprocessing the ticket. | ||||||||||||||||||||
| 34 | 0 | $self->ticket->payload->delete_implicit_items; | |||||||||||||||||||
| 35 | 0 | $self->ticket->payload->transactions_clear; | |||||||||||||||||||
| 36 | 0 | $self->before_object_type_iteration; | |||||||||||||||||||
| 37 | 0 | for my $object_type ($self->object_type_iteration_order) { | |||||||||||||||||||
| 38 | 0 | for my $payload_item ( | |||||||||||||||||||
| 39 | $self->ticket->payload->get_list_for_object_type($object_type)) { | ||||||||||||||||||||
| 40 | 0 | $self->calc_implicit_tx($object_type, $payload_item, | |||||||||||||||||||
| 41 | $self->delegate->CTX_BEFORE); | ||||||||||||||||||||
| 42 | 0 | $self->calc_explicit_tx($object_type, $payload_item); | |||||||||||||||||||
| 43 | 0 | $self->calc_implicit_tx($object_type, $payload_item, | |||||||||||||||||||
| 44 | $self->delegate->CTX_AFTER); | ||||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | 0 | $self->after_object_type_iteration; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | # Two events that subclasses might want to handle | ||||||||||||||||||||
| 51 | 0 | ▶ | sub before_object_type_iteration { } | ||||||||||||||||||
|
Subroutine
before_object_type_iteration: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 52 | 0 | ▶ | sub after_object_type_iteration { } | ||||||||||||||||||
|
Subroutine
after_object_type_iteration: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | sub calc_explicit_tx { | ||||||||||||||||||
|
Subroutine
calc_explicit_tx: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 55 | 0 | my ($self, $object_type, $payload_item) = @_; | |||||||||||||||||||
| 56 | 0 | $self->ticket->payload->add_transaction( | |||||||||||||||||||
| 57 | object_type => $object_type, | ||||||||||||||||||||
| 58 | command => $payload_item->command, | ||||||||||||||||||||
| 59 | type => $self->delegate->TXT_EXPLICIT, | ||||||||||||||||||||
| 60 | status => $self->delegate->TXS_RUNNING, | ||||||||||||||||||||
| 61 | payload_item => $payload_item, | ||||||||||||||||||||
| 62 | necessity => $self->delegate->TXN_MANDATORY, | ||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | # find and set implicit transactions in the current object. | ||||||||||||||||||||
| 67 | 0 | ▶ | sub calc_implicit_tx { | ||||||||||||||||||
|
Subroutine
calc_implicit_tx: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 68 | 0 | my ($self, $object_type, $payload_item, $context) = @_; | |||||||||||||||||||
| 69 | 0 | ▶ | our $factory ||= $self->delegate->make_obj('transaction_factory'); | ||||||||||||||||||
|
Condition0%0/3
our $factory ||= $self->delegate->make_obj("transaction_factory")
MC/DC0%0/2
our $factory ||= $self->delegate->make_obj("transaction_factory")
our $factory
$self->delegate->make_obj("transaction_factory")
Truth table0%0/3
A ||= B
A= our $factoryB= $self->delegate->make_obj("transaction_factory")
| |||||||||||||||||||||
| 70 | 0 | assert_defined $context, 'called without context.'; | |||||||||||||||||||
| 71 | 0 | assert_defined $object_type, 'called without object_type.'; | |||||||||||||||||||
| 72 | 0 | assert_defined $payload_item, 'called without payload item.'; | |||||||||||||||||||
| 73 | $factory->gen_txsel_handler( | ||||||||||||||||||||
| 74 | $object_type, | ||||||||||||||||||||
| 75 | $payload_item->{command}, | ||||||||||||||||||||
| 76 | 0 | $context, | |||||||||||||||||||
| 77 | payload_item => $payload_item, | ||||||||||||||||||||
| 78 | ticket => $self->ticket, | ||||||||||||||||||||
| 79 | )->calc_implicit_tx; | ||||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | 1 | 1; | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||