| 1 | package OpenInteract2::ActionResolver::NameAndTask; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # $Id: NameAndTask.pm,v 1.2 2005/03/02 15:31:34 lachoy Exp $ | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 87 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 87 | ▶ | use base qw( OpenInteract2::ActionResolver ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 87 | ▶ | use Log::Log4perl qw( get_logger ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 87 | ▶ | use OpenInteract2::Constants qw( LOG_ACTION ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 87 | ▶ | use OpenInteract2::Context qw( CTX ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 87 | $OpenInteract2::ActionResolver::NameAndTask::VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/); | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 87 | my ( $log ); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 87 | ▶ | sub get_name { return 'name_from_url' } | ||||||||||||||||||
|
Subroutine
get_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | ▶ | sub get_order { return 9 } | ||||||||||||||||||
|
Subroutine
get_order: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | ▶ | sub resolve { | ||||||||||||||||||
|
Subroutine
resolve: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||
| 20 | 0 | my ( $self, $request, $url ) = @_; | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | $log ||= get_logger( LOG_ACTION ); | ||||||||||||||||||
|
Condition0%0/3
$log ||= get_logger("OI2.ACTION")
MC/DC0%0/2
$log ||= get_logger("OI2.ACTION")
$log
get_logger("OI2.ACTION")
Truth table0%0/3
A ||= B
A= $logB= get_logger("OI2.ACTION")
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | my ( $action_name, $task_name, @params ) = OpenInteract2::URL->parse( $url ); | |||||||||||||||||||
| 25 | 0 | ▶ | return undef unless ( $action_name ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | $log->is_info && | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | $log->info( "Lookup action '$action_name' from context" ); | ||||||||||||||||||||
| 29 | 0 | my $action = eval { | |||||||||||||||||||
| 30 | 0 | CTX->lookup_action( $action_name, { REQUEST_URL => $url } ) | |||||||||||||||||||
| 31 | }; | ||||||||||||||||||||
| 32 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | 0 | $log->warn( "Caught exception from context trying to lookup ", | |||||||||||||||||||
| 34 | "action '$action_name': $@" ); | ||||||||||||||||||||
| 35 | 0 | return undef; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | $log->is_info && | ||||||||||||||||||||
| 38 | 0 | ▶ | $log->info( "Found action '", ref( $action ), "'" ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 0 | ▶ | if ( $task_name ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 0 | $action->task( $task_name ); | |||||||||||||||||||
| 41 | 0 | ▶ | $log->is_info && | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | $log->info( "Assigned task '$task_name' to action" ); | ||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | 0 | $self->assign_additional_params_from_url( $request, @params ); | |||||||||||||||||||
| 45 | 0 | return $action | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 87 | OpenInteract2::ActionResolver->register_factory_type( get_name() => __PACKAGE__ ); | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 87 | 1; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||