| 1 | package Gapp::Action::Registry; | ||||||||||
| 2 | { | ||||||||||
| 3 | 1 | $Gapp::Action::Registry::VERSION = '0.60'; | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use MooseX::SemiAffordanceAccessor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use MooseX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use MooseX::Types::Moose qw( Object HashRef ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | has 'actions' => ( | ||||||||||
| 13 | is => 'bare', | ||||||||||
| 14 | isa => HashRef, | ||||||||||
| 15 | 0 | ▶ | default => sub { { } }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 16 | 1 | traits => [ qw( Hash )], | |||||||||
| 17 | handles => { | ||||||||||
| 18 | _set_action => 'set', | ||||||||||
| 19 | actions => 'values', | ||||||||||
| 20 | action => 'get', | ||||||||||
| 21 | action_list => 'keys', | ||||||||||
| 22 | has_action => 'exists', | ||||||||||
| 23 | } | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub add_action { | ||||||||
|
Subroutine
add_action: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 27 | 0 | my ( $self, $action ) = @_; | |||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | $action = Gapp::Action->new( $action ) if ! is_Object($action); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | $self->_set_action( $action->name, $action ); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub perform { | ||||||||
|
Subroutine
perform: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 35 | 0 | my ( $self, $action, @args ) = @_; | |||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | $self->meta->throw_error( qq[action ($action) does not exist] ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | if ! $self->has_action( $action ); | ||||||||||
| 39 | |||||||||||
| 40 | 0 | $self->action( $action )->perform( $self, @args ); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 46 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 47 | |||||||||||
| 48 | 1 | 1; | |||||||||
| 49 | |||||||||||
| 50 | __END__ | ||||||||||