WidgetRole.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 43 CC 2 SCAR 10.6
CC
2
Cov
0%
import
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.9
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2012-2024 -- leonerd@leonerd.org.uk
5  
6 package Tickit::WidgetRole 0.54;
7  
8 use v5.14;
9 use warnings;
10  
11 use Carp;
12  
13 use meta 0.008;
14 no warnings 'meta::experimental';
15  
16 BEGIN {
17 # Since we have meta, we can use it to fake up a set_subname and avoid
18 # pulling in Sub::Util
19 *set_subname = sub {
20 my ( $name, $sub ) = @_;
21 meta::for_reference( $sub )->set_subname( $name );
22 return $sub;
23 };
24 }
25  
26 sub import
27 {
28 my $pkg = caller;
29 my $class = shift;
30  
31 my $subs = $class->export_subs_for( $pkg, @_ );
32  
33 use Object::Pad 0.808 ':experimental(mop)';
34 if( my $meta = Object::Pad::MOP::Class->try_for_class( $pkg ) ) {
35 $meta->add_method( $_ => set_subname $_ => $subs->{$_} ) for keys %$subs;
36 }
37 else {
38 carp "Using legacy Tickit::WidgetRole exporter for non-class";
39  
40 my $metapkg = meta::package->get( $pkg );
41  
42 $metapkg->add_named_sub( $_ => $subs->{$_} ) for keys %$subs;
43 }
44 }
45  
46 0x55AA;