File Coverage

blib/lib/Class/XSDelegation.pm
Criterion Covered Total %
statement 23 27 85.1
branch 2 4 50.0
condition 6 14 42.8
subroutine 6 7 85.7
pod n/a
total 37 52 71.1


line stmt bran cond sub pod time code
1 1     1   638 use 5.008008;
  1         3  
2 1     1   6 use strict;
  1         2  
  1         39  
3 1     1   5 use warnings;
  1         2  
  1         57  
4 1     1   6 use Class::XSConstructor ();
  1         2  
  1         237  
5              
6             package Class::XSDelegation;
7              
8             our $AUTHORITY = 'cpan:TOBYINK';
9             our $VERSION = '0.023006';
10              
11             sub import {
12 0     1   0 my $class = shift;
13            
14 1         14 my $package;
15 1 50       2 if ( 'SCALAR' eq ref $_[0] ) {
16 1         5 $package = ${+shift};
  0         0  
17             }
18 0   33     0 $package ||= our($SETUP_FOR) || caller;
      33        
19            
20 1         12 for my $delegation ( @_ ) {
21 1         3 my ( $methodname, $handler_slot, $handler_method, $opts ) = @$delegation;
22 3   50     8 $opts ||= {};
23            
24             my @XS_args = (
25             "$package\::$methodname",
26             $handler_slot,
27             $handler_method,
28             $opts->{curry} || $opts->{curried} || undef,
29             !!( $opts->{is_accessor} || $opts->{accessor} || 0 ),
30 3   50     8 !!( $opts->{is_try} || $opts->{try} || 0 ),
      50        
      50        
31             );
32            
33 3 50       44 if (our $REDEFINE) {
34 1     1   6 no warnings 'redefine';
  1     0   3  
  1         173  
35 3         8 Class::XSConstructor::install_delegation( @XS_args );
36             }
37             else {
38 0         0 Class::XSConstructor::install_delegation( @XS_args );
39             }
40             }
41             }
42              
43             1;
44              
45             __END__