| 1 | package Shell::Amazon::S3::CommandDispatcher; | ||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Module::Pluggable::Object; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Class::MOP; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Shell::Amazon::S3::Utils; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | has 'dispatch_table' => ( | ||||||||||
| 8 | is => 'ro', | ||||||||||
| 9 | isa => 'HashRef', | ||||||||||
| 10 | required => 1, | ||||||||||
| 11 | default => sub { | ||||||||||
| 12 | 0 | ▶ | my $finder = Module::Pluggable::Object->new( | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 13 | search_path => 'Shell::Amazon::S3::Command', ); | ||||||||||
| 14 | 0 | my @commands = $finder->plugins; | |||||||||
| 15 | 0 | Class::MOP::load_class($_) for @commands; | |||||||||
| 16 | my %table | ||||||||||
| 17 | 0 | = map { Shell::Amazon::S3::Utils->classsuffix($_) => $_->new } | |||||||||
| 18 | @commands; | ||||||||||
| 19 | 0 | \%table; | |||||||||
| 20 | } | ||||||||||
| 21 | 1 | ); | |||||||||
| 22 | |||||||||||
| 23 | sub dispatch { | ||||||||||
| 24 | 0 | ▶ | my ( $self, $command, $args ) = @_; | ||||||||
|
Subroutine
dispatch: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 25 | 0 | my $result; | |||||||||
| 26 | 0 | ▶ | if ( exists $self->dispatch_table->{$command} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | $result = $self->dispatch_table->{$command}->do_execute($args); | |||||||||
| 28 | } | ||||||||||
| 29 | else { | ||||||||||
| 30 | 0 | $result = 'Unknown command:' . $command; | |||||||||
| 31 | } | ||||||||||
| 32 | 0 | $result; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 36 | |||||||||||
| 37 | 1 | 1; | |||||||||