blib/lib/Gapp/Meta/Widget/Native/Role/HasMnemonic.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 56 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Gapp::Meta::Widget::Native::Role::HasMnemonic;
2 {
3 $Gapp::Meta::Widget::Native::Role::HasMnemonic::VERSION = '0.60';
4 }
5  
6 use Moose::Role;
7 use MooseX::SemiAffordanceAccessor;
8  
9 use Gapp::Actions::Util qw( parse_action );
10 use Gapp::Types qw( GappAction );
11  
12 has 'mnemonic' => (
13 is => 'rw',
14 isa => 'Maybe[Str]',
15 );
16  
17 has 'use_mnemonic' => (
18 is => 'rw',
19 isa => 'Bool',
20 default => 1,
21 );
22  
23 before _build_gobject => sub {
24 my ( $self ) = @_;
25
26 # fetch mnemonic from action
27 if ( $self->can('action') ) {
28 my ( $action, @args ) = parse_action ( $self->action );
29 if ( is_GappAction ( $action ) && $action->mnemonic ) {
30 if ( ! $self->label && ! $self->mnemonic ) {
31 $self->set_mnemonic( $action->mnemonic );
32 }
33 }
34 }
35
36 # if mnemonic and use_mnemonic, set the constructor args
37 if ( $self->mnemonic and $self->use_mnemonic ) {
38 $self->set_constructor( 'new_with_mnemonic' );
39 $self->set_args( [ $self->mnemonic] );
40 }
41
42  
43 };
44  
45  
46 1;
47  
48  
49 __END__