| 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::Service::Interface::SOAP; | ||||||||||||||||||||||||||||
| 6 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | $Data::Conveyor::Service::Interface::SOAP::VERSION = '1.103130'; | |||||||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Stage-based conveyor-belt-like ticket handling system | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Error ':try'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use once; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use parent 'Data::Conveyor::Service::Interface'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=5.1
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 17 | 0 | ▶ | ONCE { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=30.5
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # Generate handlers for all methods listed in the Service Methods | ||||||||||||||||||||||||||||
| 20 | # object. They are being generated into this package. If you need | ||||||||||||||||||||||||||||
| 21 | # custom implementations for some handlers, override them in the | ||||||||||||||||||||||||||||
| 22 | # appropriate subclass. | ||||||||||||||||||||||||||||
| 23 | 0 | for my $command ($self->svc->get_method_names) { | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # Generate a separate method for each alias, but not that the | ||||||||||||||||||||||||||||
| 26 | # service method for the standard name will be called! | ||||||||||||||||||||||||||||
| 27 | 0 | for my $method ($command, | |||||||||||||||||||||||||||
| 28 | $self->svc->get_aliases_for_method($command)) { | ||||||||||||||||||||||||||||
| 29 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # separate lexical var ($meth1) for closures | ||||||||||||||||||||||||||||
| 32 | 0 | my $meth1 = $method; | |||||||||||||||||||||||||||
| 33 | 0 | ▶ | unless (defined *{$meth1}{CODE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $::PTAGS | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | && $::PTAGS->add_tag($meth1, __FILE__, __LINE__ + 1); | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | *$meth1 = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | local $DB::sub = local *__ANON__ = | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||
| 38 | "Data::Conveyor::Service::Interface::SOAP::${meth1}" | ||||||||||||||||||||||||||||
| 39 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | 0 | $self->run_service_method($command, $self->args); | |||||||||||||||||||||||||||
| 42 | 0 | }; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 0 | }; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub run_service_method { | ||||||||||||||||||||||||||
|
Subroutine
run_service_method: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 0 | my ($self, $method, %opt) = @_; | |||||||||||||||||||||||||||
| 51 | 0 | $self->svc->apply_param_aliases_and_defaults($method => \%opt); | |||||||||||||||||||||||||||
| 52 | 0 | my $result_object; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 54 | 0 | $result_object = $self->svc->run_method($method, %opt); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | catch Error::Hierarchy with { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 57 | 0 | my $E = shift; | |||||||||||||||||||||||||||
| 58 | 0 | $result_object = $self->delegate->make_obj('service_result_scalar'); | |||||||||||||||||||||||||||
| 59 | 0 | $result_object->exception($E); | |||||||||||||||||||||||||||
| 60 | 0 | }; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | # Apparently the most preferred of all the fucked-up output formats, so we | ||||||||||||||||||||||||||||
| 63 | # use it as a default here. If the SOAP user expects something even more | ||||||||||||||||||||||||||||
| 64 | # idiotic, subclass the specific SOAP method and munge the output. | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | unless ($result_object->is_ok) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | return +{ | ||||||||||||||||||||||||||||
| 67 | 0 | message => sprintf("%s", $result_object->exception), | |||||||||||||||||||||||||||
| 68 | state => 1, | ||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if (exists($opt{pure_result}) && $opt{pure_result}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $opt{"pure_result"} and $opt{"pure_result"}
MC/DC0%0/2
exists $opt{"pure_result"} and $opt{"pure_result"}
exists $opt{"pure_result"}
$opt{"pure_result"}
Truth table0%0/3
A and B
A= exists $opt{"pure_result"}B= $opt{"pure_result"}
| |||||||||||||||||||||||||||||
| 72 | return +{ | ||||||||||||||||||||||||||||
| 73 | 0 | state => 0, | |||||||||||||||||||||||||||
| 74 | result => $result_object, | ||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # FIXME: Convince the SOAP user to accept standard results, then make this | ||||||||||||||||||||||||||||
| 79 | # cruft go away. | ||||||||||||||||||||||||||||
| 80 | 0 | my $soap_result; | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($self->delegate->isa_type($result_object, 'service_result_tabular')) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 82 | 0 | $soap_result = { | |||||||||||||||||||||||||||
| 83 | state => 0, | ||||||||||||||||||||||||||||
| 84 | result => scalar($result_object->result_as_list_of_hashes), | ||||||||||||||||||||||||||||
| 85 | }; | ||||||||||||||||||||||||||||
| 86 | } elsif (ref $result_object->result eq 'HASH') { | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # scalar result object, but contains a hash | ||||||||||||||||||||||||||||
| 89 | $soap_result = { | ||||||||||||||||||||||||||||
| 90 | state => 0, | ||||||||||||||||||||||||||||
| 91 | 0 | %{ $result_object->result }, | |||||||||||||||||||||||||||
| 92 | }; | ||||||||||||||||||||||||||||
| 93 | } else { | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | # scalar result object, doesn't contain a hash | ||||||||||||||||||||||||||||
| 96 | 0 | $soap_result = { | |||||||||||||||||||||||||||
| 97 | state => 0, | ||||||||||||||||||||||||||||
| 98 | result => scalar($result_object->result), | ||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # Something to munge, sir? | ||||||||||||||||||||||||||||
| 103 | # You can specify something like | ||||||||||||||||||||||||||||
| 104 | # | ||||||||||||||||||||||||||||
| 105 | # use constant MUNGE_OUTPUT => ( | ||||||||||||||||||||||||||||
| 106 | # foobar => [ frobnicate => 'some_key1', 'some_key2' ], | ||||||||||||||||||||||||||||
| 107 | # ); | ||||||||||||||||||||||||||||
| 108 | # | ||||||||||||||||||||||||||||
| 109 | # and this code will effectively call | ||||||||||||||||||||||||||||
| 110 | # | ||||||||||||||||||||||||||||
| 111 | # $self->munge_frobnicate($soap_result, 'some_key1', 'some_key2'); | ||||||||||||||||||||||||||||
| 112 | 0 | my %munge_output = $self->every_hash('MUNGE_OUTPUT'); | |||||||||||||||||||||||||||
| 113 | 0 | ▶ | return $soap_result unless exists $munge_output{$method}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | my ($munge_method, @munge_args) = @{ $munge_output{$method} }; | |||||||||||||||||||||||||||
| 115 | 0 | $munge_method = "munge_$munge_method"; | |||||||||||||||||||||||||||
| 116 | 0 | $self->$munge_method($soap_result, @munge_args); | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | # keep this close to the code where it is being used so that when sanity | ||||||||||||||||||||||||||||
| 120 | # prevails, it can be deleted quickly. | ||||||||||||||||||||||||||||
| 121 | 1 | ▶ | use constant MUNGE_OUTPUT => (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 122 | 1 | 1; | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | __END__ | ||||||||||||||||||||||||||||