| 1 | 2 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Data::Conveyor::Service::Methods; | ||||||||||||||||||||||||||||
| 6 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | $Data::Conveyor::Service::Methods::VERSION = '1.103130'; | |||||||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Stage-based conveyor-belt-like ticket handling system | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||
| 12 | # Wrapper around service methods coming from different classes. This class | ||||||||||||||||||||||||||||
| 13 | # exists to avoid the situation where every service interface has to know the | ||||||||||||||||||||||||||||
| 14 | # location of each service methods. | ||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Error ':try'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use parent 'Data::Conveyor::Service'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # generate parameter specs from an efficient getopt-like input format | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub PARAMS { | ||||||||||||||||||||||||||
|
Subroutine
PARAMS: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 0 | my ($self, @spec) = @_; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # spec could be something like: | ||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||
| 24 | # "+domain|d=s Domain name.", | ||||||||||||||||||||||||||||
| 25 | # "?logtest|l Don't delete the domain, just write the log ticket.", | ||||||||||||||||||||||||||||
| 26 | # "?force|f Disregard the 'SPR' flag.", | ||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||
| 28 | # <necessity><name>|<short>[=<type>][><default>] | ||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||
| 30 | # necessity: | ||||||||||||||||||||||||||||
| 31 | # '+' = mandatory | ||||||||||||||||||||||||||||
| 32 | # '?' = optional | ||||||||||||||||||||||||||||
| 33 | # name, short: parameter names | ||||||||||||||||||||||||||||
| 34 | # type: '=s' for string, none for boolean | ||||||||||||||||||||||||||||
| 35 | # | ||||||||||||||||||||||||||||
| 36 | # type and default are optional | ||||||||||||||||||||||||||||
| 37 | 0 | my @params; | |||||||||||||||||||||||||||
| 38 | 0 | for my $spec (@spec) { | |||||||||||||||||||||||||||
| 39 | 0 | my ($getopt, $description) = split /\s+/, $spec, 2; | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | $getopt =~ /^([+?])(\w+)(\|\w+)?(=\w+)?(>.*)?$/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | or die | ||||||||||||||||||||||||||||
| 42 | qq!Can't parse service method's parameter specification "$getopt" - use the "<necessity><name>[|<short>][=<type>][><default>]" format!; | ||||||||||||||||||||||||||||
| 43 | 0 | my ($necessity, $name, $short, $type, $default) = ($1, $2, $3, $4, $5); | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | defined($_) || ($_ = '') for $necessity, $name, $short, $type, $default; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | $short =~ s/^\|//; | |||||||||||||||||||||||||||
| 46 | 0 | my %necessity_map = ( | |||||||||||||||||||||||||||
| 47 | '+' => $self->delegate->SIP_MANDATORY, | ||||||||||||||||||||||||||||
| 48 | '?' => $self->delegate->SIP_OPTIONAL, | ||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||
| 50 | $necessity = | ||||||||||||||||||||||||||||
| 51 | length $necessity | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | ? $necessity_map{$necessity} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | : $self->delegate->SIP_MANDATORY; | ||||||||||||||||||||||||||||
| 54 | 0 | my %type_map = ('=s' => $self->delegate->SIP_STRING,); | |||||||||||||||||||||||||||
| 55 | 0 | ▶ | $type = length $type ? $type_map{$type} : $self->delegate->SIP_BOOLEAN; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | $default =~ s/^>//; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # The 'description' may yet contain 'alias' definitions - if so, split | ||||||||||||||||||||||||||||
| 59 | # them up. Note that not all service interfaces need to support | ||||||||||||||||||||||||||||
| 60 | # aliases - typically, a shell interface won't, but a SOAP interface | ||||||||||||||||||||||||||||
| 61 | # might, to support legacy SOAP calls. | ||||||||||||||||||||||||||||
| 62 | 0 | my $aliases = []; | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ($description =~ /^=([\w,]+)\s+(.*)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $description = $2; | |||||||||||||||||||||||||||
| 65 | 0 | $aliases = [ split /,/ => $1 ]; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | push @params => { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | name => $name, | ||||||||||||||||||||||||||||
| 69 | short => $short, | ||||||||||||||||||||||||||||
| 70 | type => $type, | ||||||||||||||||||||||||||||
| 71 | necessity => $necessity, | ||||||||||||||||||||||||||||
| 72 | aliases => $aliases, | ||||||||||||||||||||||||||||
| 73 | description => $description, | ||||||||||||||||||||||||||||
| 74 | (length $default ? (default => $default) : ()), | ||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 0 | return (params => \@params); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub SERVICE_METHODS { | ||||||||||||||||||||||||||
|
Subroutine
SERVICE_METHODS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | 0 | dump => { | |||||||||||||||||||||||||||
| 82 | object => 'ticket', | ||||||||||||||||||||||||||||
| 83 | $_[0]->PARAMS( | ||||||||||||||||||||||||||||
| 84 | "+ticket|t=s Ticket number", | ||||||||||||||||||||||||||||
| 85 | "?raw|r Dump ticket as-is, not comparable", | ||||||||||||||||||||||||||||
| 86 | ), | ||||||||||||||||||||||||||||
| 87 | description => 'Uses Data::Dumper to dump a ticket.', | ||||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||||
| 89 | ydump => { | ||||||||||||||||||||||||||||
| 90 | object => 'ticket', | ||||||||||||||||||||||||||||
| 91 | $_[0]->PARAMS("+ticket|t=s Ticket number",), | ||||||||||||||||||||||||||||
| 92 | description => 'Uses YAML to dump a ticket.', | ||||||||||||||||||||||||||||
| 93 | }, | ||||||||||||||||||||||||||||
| 94 | get_ticket_payload => { | ||||||||||||||||||||||||||||
| 95 | object => 'ticket', | ||||||||||||||||||||||||||||
| 96 | $_[0]->PARAMS("+ticket|t=s Ticket number",), | ||||||||||||||||||||||||||||
| 97 | description => "Show the given ticket's payload.", | ||||||||||||||||||||||||||||
| 98 | }, | ||||||||||||||||||||||||||||
| 99 | exceptions => { | ||||||||||||||||||||||||||||
| 100 | object => 'ticket', | ||||||||||||||||||||||||||||
| 101 | $_[0]->PARAMS( | ||||||||||||||||||||||||||||
| 102 | "+ticket|t=s Ticket number", | ||||||||||||||||||||||||||||
| 103 | "?raw|r Print raw exception, not stringified", | ||||||||||||||||||||||||||||
| 104 | ), | ||||||||||||||||||||||||||||
| 105 | description => 'Shows all exceptions of a ticket.', | ||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||
| 107 | clear_exceptions => { | ||||||||||||||||||||||||||||
| 108 | object => 'ticket', | ||||||||||||||||||||||||||||
| 109 | $_[0]->PARAMS("+ticket|t=s Ticket number",), | ||||||||||||||||||||||||||||
| 110 | description => 'Shows all exceptions of a ticket.', | ||||||||||||||||||||||||||||
| 111 | }, | ||||||||||||||||||||||||||||
| 112 | exceptions_structured => { | ||||||||||||||||||||||||||||
| 113 | object => 'ticket', | ||||||||||||||||||||||||||||
| 114 | aliases => ['get_errors'], | ||||||||||||||||||||||||||||
| 115 | $_[0]->PARAMS( | ||||||||||||||||||||||||||||
| 116 | "+ticket|t=s Ticket number", | ||||||||||||||||||||||||||||
| 117 | "?object|o=s Restrict to this object type (e.g., 'person')", | ||||||||||||||||||||||||||||
| 118 | ), | ||||||||||||||||||||||||||||
| 119 | description => "Get a ticket's exceptions in a structured form.", | ||||||||||||||||||||||||||||
| 120 | }, | ||||||||||||||||||||||||||||
| 121 | delete_exception => { | ||||||||||||||||||||||||||||
| 122 | object => 'ticket', | ||||||||||||||||||||||||||||
| 123 | aliases => ['del_error'], | ||||||||||||||||||||||||||||
| 124 | $_[0]->PARAMS( | ||||||||||||||||||||||||||||
| 125 | "+ticket|t=s Ticket number", | ||||||||||||||||||||||||||||
| 126 | "+uuid|u=s UUID of the exception to delete", | ||||||||||||||||||||||||||||
| 127 | ), | ||||||||||||||||||||||||||||
| 128 | description => "Delete an exception from a ticket.", | ||||||||||||||||||||||||||||
| 129 | examples => [ | ||||||||||||||||||||||||||||
| 130 | { ticket => '200707301444.003384594', | ||||||||||||||||||||||||||||
| 131 | uuid => '4162F712-1DD2-11B2-B17E-C09EFE1DC403', | ||||||||||||||||||||||||||||
| 132 | }, | ||||||||||||||||||||||||||||
| 133 | ], | ||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||
| 135 | journal => { | ||||||||||||||||||||||||||||
| 136 | object => 'ticket', | ||||||||||||||||||||||||||||
| 137 | $_[0]->PARAMS("+ticket|t=s Ticket number",), | ||||||||||||||||||||||||||||
| 138 | description => 'Shows the journal of a ticket.', | ||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||
| 140 | set_stage => { | ||||||||||||||||||||||||||||
| 141 | object => 'ticket', | ||||||||||||||||||||||||||||
| 142 | $_[0]->PARAMS( | ||||||||||||||||||||||||||||
| 143 | "+ticket|t=s =ticket_no Ticket number", | ||||||||||||||||||||||||||||
| 144 | "+stage|g=s Set to this stage (e.g., 'starten_policy')", | ||||||||||||||||||||||||||||
| 145 | ), | ||||||||||||||||||||||||||||
| 146 | description => "Set a ticket's stage.", | ||||||||||||||||||||||||||||
| 147 | }, | ||||||||||||||||||||||||||||
| 148 | top => { | ||||||||||||||||||||||||||||
| 149 | object => 'monitor', | ||||||||||||||||||||||||||||
| 150 | $_[0]->PARAMS( | ||||||||||||||||||||||||||||
| 151 | "?all|a Report all relevant status values (will be slower)", | ||||||||||||||||||||||||||||
| 152 | ), | ||||||||||||||||||||||||||||
| 153 | description => | ||||||||||||||||||||||||||||
| 154 | "Show how many tickets there are currently in each stage. Unless the 'all' argument is given, only running and 'on hold' tickets (status 'R' and 'H') are reported.", | ||||||||||||||||||||||||||||
| 155 | }, | ||||||||||||||||||||||||||||
| 156 | ; | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub get_method_names { | ||||||||||||||||||||||||||
|
Subroutine
get_method_names: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 160 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | $self->{_service_methods} ||= $self->every_hash('SERVICE_METHODS'); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_service_methods"} ||= $self->every_hash("SERVICE_METHODS")
MC/DC0%0/2
$self->{"_service_methods"} ||= $self->every_hash("SERVICE_METHODS")
$self->{"_service_methods"}
$self->every_hash("SERVICE_METHODS")
Truth table0%0/3
A ||= B
A= $self->{"_service_methods"}B= $self->every_hash("SERVICE_METHODS")
| |||||||||||||||||||||||||||||
| 162 | 0 | my %methods = %{ $self->{_service_methods} }; | |||||||||||||||||||||||||||
| 163 | 0 | my @keys = keys %methods; | |||||||||||||||||||||||||||
| 164 | 0 | ▶ | wantarray ? @keys : \@keys; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub get_spec_for_method { | ||||||||||||||||||||||||||
|
Subroutine
get_spec_for_method: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 168 | 0 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 169 | 0 | ▶ | $self->{_service_methods} ||= $self->every_hash('SERVICE_METHODS'); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_service_methods"} ||= $self->every_hash("SERVICE_METHODS")
MC/DC0%0/2
$self->{"_service_methods"} ||= $self->every_hash("SERVICE_METHODS")
$self->{"_service_methods"}
$self->every_hash("SERVICE_METHODS")
Truth table0%0/3
A ||= B
A= $self->{"_service_methods"}B= $self->every_hash("SERVICE_METHODS")
| |||||||||||||||||||||||||||||
| 170 | 0 | ▶ | $self->{_service_methods}{$method} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | or throw Error::Hierarchy::Internal::CustomMessage( | ||||||||||||||||||||||||||||
| 172 | custom_message => sprintf 'no service method [%s]', | ||||||||||||||||||||||||||||
| 173 | $method | ||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub get_params_for_method { | ||||||||||||||||||||||||||
|
Subroutine
get_params_for_method: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 0 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 179 | 0 | my $params = $self->get_spec_for_method($method)->{params}; | |||||||||||||||||||||||||||
| 180 | 0 | ▶ | $params = [] unless defined $params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | wantarray ? @$params : $params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub get_description_for_method { | ||||||||||||||||||||||||||
|
Subroutine
get_description_for_method: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 0 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 186 | 0 | $self->get_spec_for_method($method)->{description}; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub get_summary_for_method { | ||||||||||||||||||||||||||
|
Subroutine
get_summary_for_method: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 190 | 0 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 191 | 0 | my $summary = $self->get_spec_for_method($method)->{summary}; | |||||||||||||||||||||||||||
| 192 | 0 | ▶ | return $summary if defined($summary) && length($summary); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $summary and length $summary
MC/DC0%0/2
defined $summary and length $summary
defined $summary
length $summary
Truth table0%0/3
A and B
A= defined $summaryB= length $summary
| |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | # if we don't have a summary, lowercase the first sentence - up to the | ||||||||||||||||||||||||||||
| 195 | # first full stop - of the description | ||||||||||||||||||||||||||||
| 196 | 0 | $summary = lc($self->get_description_for_method($method)); | |||||||||||||||||||||||||||
| 197 | 0 | $summary =~ s/\..*//s; # remove everything from the first full stop | |||||||||||||||||||||||||||
| 198 | 0 | $summary; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub get_examples_for_method { | ||||||||||||||||||||||||||
|
Subroutine
get_examples_for_method: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 202 | 0 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 203 | 0 | my $examples = $self->get_spec_for_method($method)->{examples}; | |||||||||||||||||||||||||||
| 204 | 0 | ▶ | $examples = [] unless defined $examples; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | wantarray ? @$examples : $examples; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub get_aliases_for_method { | ||||||||||||||||||||||||||
|
Subroutine
get_aliases_for_method: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 209 | 0 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 210 | 0 | my $aliases = $self->get_spec_for_method($method)->{aliases}; | |||||||||||||||||||||||||||
| 211 | 0 | ▶ | $aliases = [] unless defined $aliases; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 0 | ▶ | wantarray ? @$aliases : $aliases; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub apply_param_aliases_and_defaults { | ||||||||||||||||||||||||||
|
Subroutine
apply_param_aliases_and_defaults: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 216 | 0 | my ($self, $method, $opts_ref) = @_; | |||||||||||||||||||||||||||
| 217 | 0 | for my $param ($self->get_params_for_method($method)) { | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | # If the parameter is defined in its standard form, don't care about | ||||||||||||||||||||||||||||
| 220 | # aliases or defaults. | ||||||||||||||||||||||||||||
| 221 | 0 | ▶ | next if defined $opts_ref->{ $param->{name} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | # If the parameter is present in one of its alias forms, copy it to | ||||||||||||||||||||||||||||
| 224 | # the standard parameter and delete the alias. We take the first | ||||||||||||||||||||||||||||
| 225 | # aliased form we encounter, in case there are several ones. | ||||||||||||||||||||||||||||
| 226 | 0 | ▶ | for my $alias (@{ $param->{aliases} || [] }) { | ||||||||||||||||||||||||||
|
Condition0%0/2
$param->{'aliases'} || []
MC/DC0%0/1
$param->{'aliases'} || []
$param->{'aliases'}
Truth table0%0/2
A
A= $param->{'aliases'}
| |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | next unless defined $opts_ref->{$alias}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | $opts_ref->{ $param->{name} } = $opts_ref->{$alias}; | |||||||||||||||||||||||||||
| 229 | 0 | delete $opts_ref->{$alias}; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | 0 | ▶ | next unless defined $param->{default}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | $opts_ref->{ $param->{name} } = $param->{default}; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub run_method { | ||||||||||||||||||||||||||
|
Subroutine
run_method: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 237 | 0 | my ($self, $method, %opt) = @_; | |||||||||||||||||||||||||||
| 238 | 0 | my $result; | |||||||||||||||||||||||||||
| 239 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 240 | 0 | my $spec = $self->get_spec_for_method($method); | |||||||||||||||||||||||||||
| 241 | 0 | my $object_type = $spec->{object}; | |||||||||||||||||||||||||||
| 242 | my $object_method = | ||||||||||||||||||||||||||||
| 243 | exists $spec->{method} | ||||||||||||||||||||||||||||
| 244 | ? $spec->{method} | ||||||||||||||||||||||||||||
| 245 | 0 | ▶ | : "sif_$method"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 0 | $result = | |||||||||||||||||||||||||||
| 247 | $self->delegate->make_obj($object_type)->$object_method (%opt); | ||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | catch Data::Conveyor::Exception::ServiceMethodHelp with { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | # this exception will be handled higher up | ||||||||||||||||||||||||||||
| 252 | 0 | $_[0]->throw; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | catch Error::Hierarchy with { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 255 | 0 | my $E = shift; | |||||||||||||||||||||||||||
| 256 | 0 | $result = $self->delegate->make_obj('service_result_scalar'); | |||||||||||||||||||||||||||
| 257 | 0 | $result->exception($E); | |||||||||||||||||||||||||||
| 258 | 0 | }; | |||||||||||||||||||||||||||
| 259 | 0 | $result; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | # Also allow service methods to be called directly on the service methods | ||||||||||||||||||||||||||||
| 263 | # object: | ||||||||||||||||||||||||||||
| 264 | # | ||||||||||||||||||||||||||||
| 265 | # $svc->foobar(...) | ||||||||||||||||||||||||||||
| 266 | # | ||||||||||||||||||||||||||||
| 267 | # is to be the same as | ||||||||||||||||||||||||||||
| 268 | # | ||||||||||||||||||||||||||||
| 269 | # $svc->run_method('foobar', ...); | ||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub DEFAULTS { () } | ||||||||||||||||||||||||||
|
Subroutine
DEFAULTS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub DESTROY { } | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 274 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 275 | 0 | (my $method = our $AUTOLOAD) =~ s/.*://; | |||||||||||||||||||||||||||
| 276 | 0 | $self->run_method($method, @_); | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | 2 | 1; | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | __END__ | ||||||||||||||||||||||||||||